spring配置文件异常

100817 141034 INFO AbstractApplicationContext.java:411 Refreshing org.springfram
ework.context.support.ClassPathXmlApplicationContext@1f9dc36: display name [org.
springframework.context.support.ClassPathXmlApplicationContext@1f9dc36]; startup
 date [Tue Aug 17 14:10:34 CST 2010]; root of context hierarchy
100817 141034 INFO XmlBeanDefinitionReader.java:323 Loading XML bean definitions
 from class path resource [context-common-default.xml]
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinit
ionParsingException: Configuration problem: Unable to locate Spring NamespaceHan
dler for XML schema namespace [http://www.springframework.org/schema/tx]
Offending resource: class path resource [context-common-default.xml]

        at org.springframework.beans.factory.parsing.FailFastProblemReporter.err
or(FailFastProblemReporter.java:68)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderC
ontext.java:85)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderC
ontext.java:80)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.er
ror(BeanDefinitionParserDelegate.java:281)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.pa
rseCustomElement(BeanDefinitionParserDelegate.java:1294)

问题原因:打包之后,jar包中META-INF目录包含了多个spring的spring.schemas文件,该文件引导有先后顺序,导致无法处理http://www.springframework.org/schema/tx的schema。
解决办法:
将原先的spring分包依赖:
<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<scope>test</scope>
		</dependency>

改用以下单个包:
<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring</artifactId>
		</dependency>

ok pass.备忘!

你可能感兴趣的:(java,spring,AOP,xml,bean)