context:component-无法定义扫描
context:component-scan cannot be defined
我对 Spring-contex 定义有疑问。当我查看其他遇到此问题的人时,通常是因为使用了错误的架构声明,但我认为我的问题并非如此。
Line 21 in XML document from ServletContext resource [/WEB-INF/spring/web-application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 67; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.
这里是xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context/spring-context-4.1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<!-- Imports the configurations of the different infrastructure systems of the application -->
<context:component-scan base-package="com.robert.login" />
<mvc:annotation-driven />
<import resource="webmvc-context.xml" />
<bean name="LoginInfo" class="com.robert.login.LoginInfo" />
</beans>
我正在使用 Spring-4.1.6
我认为你需要解决这个问题:
xmlns:context="http://www.springframework.org/schema/context/spring-context-4.1.xsd"
应该是:
xmlns:context="http://www.springframework.org/schema/context"
我对 Spring-contex 定义有疑问。当我查看其他遇到此问题的人时,通常是因为使用了错误的架构声明,但我认为我的问题并非如此。
Line 21 in XML document from ServletContext resource [/WEB-INF/spring/web-application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 67; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.
这里是xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context/spring-context-4.1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<!-- Imports the configurations of the different infrastructure systems of the application -->
<context:component-scan base-package="com.robert.login" />
<mvc:annotation-driven />
<import resource="webmvc-context.xml" />
<bean name="LoginInfo" class="com.robert.login.LoginInfo" />
</beans>
我正在使用 Spring-4.1.6
我认为你需要解决这个问题:
xmlns:context="http://www.springframework.org/schema/context/spring-context-4.1.xsd"
应该是:
xmlns:context="http://www.springframework.org/schema/context"