Я создаю автономное приложение Sava с Spring для обработки доступа JDBC. Приложение отлично работает на каждом тесте, и я решил, что мне нужна банка для развертывания наших клиентов.
Они могут не иметь 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.
Файл applicationContext.xml находится в файле projectbase/src/main/resources. И он помещается в базу целей /packagename.
ПриложениеContext.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>
Это все, что я могу думать, что может быть полезно. Я буду предоставлять дополнительную информацию по запросу.