cvc-complex-type.2.4.d: Invalid content was found starting with element 'ref'. No child element is expected at this point.

来源:6-2 ProxyFactoryBean及相关内容(上)

慕粉3917970

2016-09-04 20:40

xml文件错误,

<?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:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="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/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">

    <bean id="bizLogicImplTarget" class="com.learn.aop.api.BizLogicImpl"></bean>
    <bean id="bizLogicImpl" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="proxyInterfaces">
            <value>com.learn.aop.api.BizLogic</value>
        </property>
        <property name="target">
            <bean class="com.learn.aop.api.BizLogicImpl"></bean>
            <ref bean="bizLogicImplTarget" />
        </property>
        <property name="interceptorNames">
            <list>
                <value>moocBeforeAdvice</value>
                <value>moocAfterReturningAdvice</value>
                <value>moocMethodInterceptor</value>
                <value>moocThrowsAdvice</value>
                <value>mooc*</value>
            </list>
        </property>
    </bean>

</beans>

写回答 关注

2回答

  • 天弈九幽
    2016-09-05 21:45:18

    说错了

    两个bean应该装到<list></list>里


    <?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:context="http://www.springframework.org/schema/context"

        xmlns:aop="http://www.springframework.org/schema/aop"

        xsi:schemaLocation="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/aop 

            http://www.springframework.org/schema/aop/spring-aop.xsd">

        <bean id="bizLogicImplTarget" class="com.learn.aop.api.BizLogicImpl"></bean>

        <bean id="bizLogicImpl" class="org.springframework.aop.framework.ProxyFactoryBean">

            <property name="proxyInterfaces">

                <value>com.learn.aop.api.BizLogic</value>

            </property>

            <property name="target">

                <bean class="com.learn.aop.api.BizLogicImpl"></bean>

                <ref bean="bizLogicImplTarget"></ref>

            </property>

            <property name="interceptorNames">

                <list>

                    <value>moocBeforeAdvice</value>

                    <value>moocAfterReturningAdvice</value>

                    <value>moocMethodInterceptor</value>

                    <value>moocThrowsAdvice</value>

                    <value>mooc*</value>

                </list>

            </property>

        </bean>


    </beans>


  • 天弈九幽
    2016-09-05 21:41:18

    <ref bean="bizLogicImplTarget" />是属性

    改为


    <?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:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xsi:schemaLocation="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/aop 
            http://www.springframework.org/schema/aop/spring-aop.xsd">

        <bean id="bizLogicImplTarget" class="com.learn.aop.api.BizLogicImpl"></bean>
        <bean id="bizLogicImpl" class="org.springframework.aop.framework.ProxyFactoryBean">
            <property name="proxyInterfaces">
                <value>com.learn.aop.api.BizLogic</value>
            </property>
            <property name="target" ref="bizLogicImplTarget">
                <bean class="com.learn.aop.api.BizLogicImpl"></bean>
            </property>
            <property name="interceptorNames">
                <list>
                    <value>moocBeforeAdvice</value>
                    <value>moocAfterReturningAdvice</value>
                    <value>moocMethodInterceptor</value>
                    <value>moocThrowsAdvice</value>
                    <value>mooc*</value>
                </list>
            </property>
        </bean>

    </beans>


Spring入门篇

为您带来IOC和AOP的基本概念及用法,为后续高级课程学习打下基础

268785 学习 · 963 问题

查看课程

相似问题