The matching wildcard is strict, but no declaration can be found for element ‘aop:scoped-proxy’

huangapple go评论122阅读模式
英文:

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

&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;

    xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
    xmlns:jpa=&quot;http://www.springframework.org/schema/data/jpa&quot;
    xmlns:tx=&quot;http://www.springframework.org/schema/tx&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;
    xsi:schemaLocation=&quot;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">

&lt;bean id=&quot;bbtra&quot; 
        class=&quot;com.bonanza.commons.services.TranslationDB&quot;
        autowire-candidate=&quot;true&quot;&gt;
    &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&gt;
    &lt;aop:scoped-proxy/&gt;
&lt;/bean&gt;

I got this error:

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element &#39;aop:scoped-proxy&#39;.

答案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:

&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;
    xsi:schemaLocation=&quot;
        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&quot;&gt;

    &lt;!-- bean definitions here --&gt;

&lt;/beans&gt;

答案2

得分: 0

通常 *.xsd 文件的引用是通过 https:// 而不是 http://,但这不是问题所在,我只是提到一下。修复问题的 XML 文件的最小更改是将 spring-tx.xsd 移动到 tx 的直接后面。然后你的 XML 编辑器中的高亮也会发生变化,例如在 IntelliJ IDEA 中,你会看到 AOP 相关的内容从灰色变为绿色。我的意思是:

&lt;beans
  xmlns=&quot;http://www.springframework.org/schema/beans&quot;
  xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
  xmlns:jpa=&quot;http://www.springframework.org/schema/data/jpa&quot;
  xmlns:tx=&quot;http://www.springframework.org/schema/tx&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;
  xsi:schemaLocation=&quot;
    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
  &quot;
&gt;

  &lt;bean id=&quot;bbtra&quot;
    class=&quot;com.bonanza.commons.services.TranslationDB&quot;
    autowire-candidate=&quot;true&quot;&gt;
    &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&gt;
    &lt;aop:scoped-proxy/&gt;
  &lt;/bean&gt;

&lt;/beans&gt;

现在所有的模式位置 schema/fooschema/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:

&lt;beans
  xmlns=&quot;http://www.springframework.org/schema/beans&quot;
  xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
  xmlns:jpa=&quot;http://www.springframework.org/schema/data/jpa&quot;
  xmlns:tx=&quot;http://www.springframework.org/schema/tx&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;
  xsi:schemaLocation=&quot;
    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
  &quot;
&gt;

  &lt;bean id=&quot;bbtra&quot;
    class=&quot;com.bonanza.commons.services.TranslationDB&quot;
    autowire-candidate=&quot;true&quot;&gt;
    &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&gt;
    &lt;aop:scoped-proxy/&gt;
  &lt;/bean&gt;

&lt;/beans&gt;

Now all schema locations schema/foo and schema/foo/spring-foo.xsd form pairs.

huangapple
  • 本文由 发表于 2020年10月10日 03:04:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/64285915.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定