0

我不知道这是否是 STS/Eclipse 或我的项目设置的问题,但 STS 抱怨我的 Spring 模式。

Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jee:jndi-lookup'.
- schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/jee/spring-jee.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root 
 element of the document is not <xsd:schema>.

Multiple annotations found at this line:
- schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tx/spring-tx.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root 
 element of the document is not <xsd:schema>.
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:advice'.

Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:config'.
- schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/aop/spring-aop.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root 
 element of the document is not <xsd:schema>.

这是我的应用程序配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <jee:jndi-lookup expected-type="java.lang.String" id="myId" jndi-name="myJndiName"/>

    <!-- Other stuff with no problems ommitted -->

    <tx:advice id="transactionAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <!-- all methods starting with 'get' are read-only -->
            <tx:method name="get*" read-only="true"/>
            <!-- other methods use the default transaction settings (see below) -->
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>

    <aop:config>
        <aop:pointcut expression="execution(* com.example.service.*.*(..) )" id="servicesPointcut"/>
        <aop:advisor advice-ref="transactionAdvice" pointcut-ref="servicesPointcut"/>
    </aop:config>

</beans>

这是我的类路径上的 spring JAR:

spring-aop-3.1.4.RELEASE.jar
spring-asm-3.1.4.RELEASE.jar
spring-batch-core-2.1.9.RELEASE.jar
spring-batch-infrastructure-2.1.9.RELEASE.jar
spring-batch-test-2.1.9.RELEASE.jar
spring-beans-3.1.4.RELEASE.jar
spring-context-3.1.4.RELEASE.jar
spring-context-support-3.1.4.RELEASE.jar
spring-core-3.1.4.RELEASE.jar
spring-data-commons-1.5.1.RELEASE.jar
spring-data-jpa-1.3.1.RELEASE.jar
spring-expression-3.1.4.RELEASE.jar
spring-jdbc-3.1.4.RELEASE.jar
spring-orm-3.1.4.RELEASE.jar
spring-oxm-3.1.4.RELEASE.jar
spring-test-3.1.4.RELEASE.jar
spring-tx-3.1.4.RELEASE.jar

查看我的项目类路径,我可以找到spring-context-3.1.4.RELEASE.jar/META-INF/spring.schemas其中包含http\://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.1.xsd. spring-aop-3.1.4.RELEASE.jar我的 AOP 标签的类路径中有一个类似的文件。

有人对如何摆脱此错误有任何建议吗?

4

1 回答 1

0

您已在类路径 spring-tx-3.1.4.RELEASE.jar 中添加,在 spring.xm 中您指的是 http://www.springframework.org/schema/tx/spring-tx.xsd。也许您使用的 xsd 声明是旧的?(即使用:http ://www.springframework.org/schema/tx/spring-tx-3.1.xsd )

于 2013-07-27T18:21:36.993 回答