我正在尝试使用Spring进行应用程序。将<aop:aspectj-autoproxy/>
放入xml配置后,我收到了XmlBeanDefinitionStoreException。
xml config
<?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:p="http://www.springframework.org/schema/p"
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">
<context:component-scan base-package="java"/>
<aop:aspectj-autoproxy/>
<bean id="beanOne" class="BeanOne"></bean>
<bean id="beanTwo" class="BeanTwo"></bean>
<bean id="Three" class="BeanThree"></bean>
<bean id="aspect" class="AspClass"></bean>
</beans>
控制台中的文字
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 12 in XML document from class path resource [context.xml] is invalid;
nested exception is org.xml.sax.SAXParseException;
lineNumber: 12; columnNumber: 29; cvc-complex-type.2.4.c:
The matching wildcard is strict, but no declaration can be found
for element 'aop:aspectj-autoproxy'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)*
你可以告诉我该怎么做。
感谢。
答案 0 :(得分:1)
好吧,也许你应该摆脱不存在的xmlns:p
,而是添加aop
的架构位置。
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
<context:component-scan base-package="java"/>
<aop:aspectj-autoproxy/>
<bean id="beanOne" class="BeanOne"></bean>
<bean id="beanTwo" class="BeanTwo"></bean>
<bean id="Three" class="BeanThree"></bean>
<bean id="aspect" class="AspClass"></bean>
</beans>