以下是我的Spring上下文.xml
文件的摘录。
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<beans:import
resource="classpath:com/batch/jobs/data-source-context.xml" />
<job id="xxxx">
<step id="loadRecord">
<tasklet>
<chunk reader="dtaFileItemReader" writer="dtaGroupWriter"
commit-interval="${job.commit.interval}" />
</tasklet>
</step>
</job>
<jee:jndi-lookup id="dataSource" jndi-name="jdbc"></jee:jndi-lookup>
<beans:bean id="incrementerParent" class="${batch.database.incrementer.class}">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="incrementerName" value="ID" />
</beans:bean>
我得到一个例外说:
nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jee:jndi-lookup'
答案 0 :(得分:9)
某处有一个不正确的名称空间声明,可能是bean和JEE。
根据documentation,JEE XMLNS声明应为:
<?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:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<!-- <bean/> definitions here -->
</beans>
答案 1 :(得分:2)
看起来spring在运行时没有找到org/springframework/ejb/config/spring-jee-3.0.xsd
。
此文件位于spring-context-3.0.x.RELESE.jar
,请检查此文件的部署是否正确。
答案 2 :(得分:2)
您正在将Spring(beans,aop和tx)2.0与Spring 3.0中的JEE模式混合在一起,这可能会导致问题。