英文:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:scoped-proxy'
问题
<beans xmlns="http://www.springframework.org/schema/beans"
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="bbtra"
class="com.bonanza.commons.services.TranslationDB"
autowire-candidate="true">
<property name="dataSource" ref="dataSource" />
<aop:scoped-proxy/>
</bean>
</beans>
Error:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:scoped-proxy'.
英文:
I have a Spring MvC project using JPA and Oracle as DB, I have this bean declaration in my servlet.xml file, but when I run a test
<beans xmlns="http://www.springframework.org/schema/beans"
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="bbtra"
class="com.bonanza.commons.services.TranslationDB"
autowire-candidate="true">
<property name="dataSource" ref="dataSource" />
<aop:scoped-proxy/>
</bean>
I got this error:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:scoped-proxy'.
答案1
得分: 0
很可能没有指定aop命名空间的模式位置:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 在这里添加bean定义 -->
</beans>
英文:
Most probably schema location of the aop namespace is not specified:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- bean definitions here -->
</beans>
答案2
得分: 0
通常 *.xsd 文件的引用是通过 https:// 而不是 http://,但这不是问题所在,我只是提到一下。修复问题的 XML 文件的最小更改是将 spring-tx.xsd 移动到 tx 的直接后面。然后你的 XML 编辑器中的高亮也会发生变化,例如在 IntelliJ IDEA 中,你会看到 AOP 相关的内容从灰色变为绿色。我的意思是:
<beans
xmlns="http://www.springframework.org/schema/beans"
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
"
>
<bean id="bbtra"
class="com.bonanza.commons.services.TranslationDB"
autowire-candidate="true">
<property name="dataSource" ref="dataSource" />
<aop:scoped-proxy/>
</bean>
</beans>
现在所有的模式位置 schema/foo 和 schema/foo/spring-foo.xsd 形成了一对。
英文:
Usually the *.xsd files are referenced by https:// instead of http://, but that is not the problem, I am just mentioning it. The minimal change to your XML file fixing the problem is moving up spring-tx.xsd to be right behind tx. Then also the highlighting in your XML editor changes, i.e. in IntelliJ IDEA you will see the AOP stuff go from grey to green. What I mean is:
<beans
xmlns="http://www.springframework.org/schema/beans"
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
"
>
<bean id="bbtra"
class="com.bonanza.commons.services.TranslationDB"
autowire-candidate="true">
<property name="dataSource" ref="dataSource" />
<aop:scoped-proxy/>
</bean>
</beans>
Now all schema locations schema/foo and schema/foo/spring-foo.xsd form pairs.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论