【发布时间】:2012-08-05 14:01:21
【问题描述】:
我注意到一个关于 Spring XML 模式的奇怪问题。
我有一个使用 spring 框架的独立 java 应用程序。只要我在 Eclipse 中运行这个应用程序,我就不会遇到任何问题。但是,当我将其打包为 jar 文件(如 link 中所述)并执行该 jar 时,出现以下异常:
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx]
Offending resource: class path resource [applicationContext.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:316)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1416)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
我在 applicationContext.xml 中有以下条目,它在 eclipse 中运行良好:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
非常感谢任何帮助。
我什至尝试将http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 更改为classpath:/org/springframework/transaction/config/spring-tx-3.1.xsd,但没有帮助。
【问题讨论】:
-
@kbdjockey - 我没有 WEB-INF/lib 结构,因为它只是一个独立的 java 应用程序。
标签: java spring jakarta-ee maven jar