欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

spring配置文件异常

程序员文章站 2022-07-14 10:42:01
...

源:http://wodar.iteye.com/blog/739210

评:

Java代码  spring配置文件异常
            
    
    博客分类: Spring  
  1. 100817 141034 INFO AbstractApplicationContext.java:411 Refreshing org.springfram  
  2. ework.context.support.ClassPathXmlApplicationContext@1f9dc36: display name [org.  
  3. springframework.context.support.ClassPathXmlApplicationContext@1f9dc36]; startup  
  4.  date [Tue Aug 17 14:10:34 CST 2010]; root of context hierarchy  
  5. 100817 141034 INFO XmlBeanDefinitionReader.java:323 Loading XML bean definitions  
  6.  from class path resource [context-common-default.xml]  
  7. Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinit  
  8. ionParsingException: Configuration problem: Unable to locate Spring NamespaceHan  
  9. dler for XML schema namespace [http://www.springframework.org/schema/tx]  
  10. Offending resource: class path resource [context-common-default.xml]  
  11.   
  12.         at org.springframework.beans.factory.parsing.FailFastProblemReporter.err  
  13. or(FailFastProblemReporter.java:68)  
  14.         at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderC  
  15. ontext.java:85)  
  16.         at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderC  
  17. ontext.java:80)  
  18.         at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.er  
  19. ror(BeanDefinitionParserDelegate.java:281)  
  20.         at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.pa  
  21. rseCustomElement(BeanDefinitionParserDelegate.java:1294)  


问题原因:打包之后,jar包中META-INF目录包含了多个spring的spring.schemas文件,该文件引导有先后顺序,导致无法处理http://www.springframework.org/schema/tx的schema。
解决办法:
将原先的spring分包依赖:

Xml代码  spring配置文件异常
            
    
    博客分类: Spring  
  1. <dependency>  
  2.             <groupId>org.springframework</groupId>  
  3.             <artifactId>spring-aop</artifactId>  
  4.         </dependency>  
  5.         <dependency>  
  6.             <groupId>org.springframework</groupId>  
  7.             <artifactId>spring-beans</artifactId>  
  8.         </dependency>  
  9.         <dependency>  
  10.             <groupId>org.springframework</groupId>  
  11.             <artifactId>spring-context</artifactId>  
  12.         </dependency>  
  13.         <dependency>  
  14.             <groupId>org.springframework</groupId>  
  15.             <artifactId>spring-context-support</artifactId>  
  16.         </dependency>  
  17.         <dependency>  
  18.             <groupId>org.springframework</groupId>  
  19.             <artifactId>spring-core</artifactId>  
  20.         </dependency>  
  21.         <dependency>  
  22.             <groupId>org.springframework</groupId>  
  23.             <artifactId>spring-jdbc</artifactId>  
  24.         </dependency>  
  25.         <dependency>  
  26.             <groupId>org.springframework</groupId>  
  27.             <artifactId>spring-tx</artifactId>  
  28.         </dependency>  
  29.         <dependency>  
  30.             <groupId>org.springframework</groupId>  
  31.             <artifactId>spring-web</artifactId>  
  32.         </dependency>  
  33.         <dependency>  
  34.             <groupId>org.springframework</groupId>  
  35.             <artifactId>spring-webmvc</artifactId>  
  36.         </dependency>  
  37.         <dependency>  
  38.             <groupId>org.springframework</groupId>  
  39.             <artifactId>spring-test</artifactId>  
  40.             <scope>test</scope>  
  41.         </dependency>  


改用以下单个包:

Xml代码  spring配置文件异常
            
    
    博客分类: Spring  
  1. <dependency>  
  2.             <groupId>org.springframework</groupId>  
  3.             <artifactId>spring</artifactId>  
  4.         </dependency>  


ok pass.备忘!