Spring <jee:jndi-lookup>标签和`SAXParseException`

nob*_*ody 6 java spring

以下是我的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>
Run Code Online (Sandbox Code Playgroud)

我得到一个例外说:

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'
Run Code Online (Sandbox Code Playgroud)

Ale*_*lex 10

你在某处有一个不正确的命名空间声明,可能是bean和JEE.

根据文档,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>
Run Code Online (Sandbox Code Playgroud)


ben*_*y23 3

您将 Spring(bean、aop 和 tx)2.0 与 Spring 3.0 中的 JEE 模式混合在一起,这可能会导致问题。