我正在使用Spring创建一个独立的Sava应用程序,以处理JDBC访问。这个应用程序在每次测试中都工作得很好,我决定需要一个jar来部署我们的客户端。
它们的类路径中可能没有spring,所以我使用maven-assembly-plugin来处理带有依赖项的jar创建。
但是,当我尝试运行应用程序时:
java -jar target/myproject-0.0.1-SNAPSHOT-jar-with-dependencies.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/p]
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)
...and so on to the database access class of this project.
主文件位于projectbase/src/ applicationContext.xml /resources中。并将其放在target/packagename库中。
The applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="dataSourceDesenv" class="org.apache.commons.dbcp.BasicDataSource"... />
<bean id="simpleJdbcDaoSupport" class="org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport"
p:dataSource-ref="dataSourceDesenv" />
<bean id="simpleJdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
<constructor-arg ref="dataSourceDesenv" />
</bean>
</beans>
https://stackoverflow.com/questions/3335203
复制相似问题