Java Spring 3.0-找不到XML架构命名空间的Spring NamespaceHandler[http://www.springframework.org/schema/security]
你知道这是什么原因吗 找不到弹簧 XML模式的命名空间处理程序 名称空间 [ 这是我的applicationContext.xml:Java Spring 3.0-找不到XML架构命名空间的Spring NamespaceHandler[http://www.springframework.org/schema/security],java,spring,maven-2,spring-security,Java,Spring,Maven 2,Spring Security,你知道这是什么原因吗 找不到弹簧 XML模式的命名空间处理程序 名称空间 [ 这是我的applicationContext.xml: <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
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/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
...
</beans:beans>
...
在我的pom.xml中,我有:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-openid</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
org.springframework.security
spring安全内核
3.0.1.1发布
org.springframework.security
spring安全openid
3.0.1.1发布
我需要添加一个额外的Maven依赖项:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
org.springframework.security
spring安全配置
3.0.1.1发布
我在尝试部署应用程序时收到了相同的错误消息。在Spring中,安全配置xml可以与applicationContext.xml不同,通常是WEB-INF文件夹中的applicationContext-security.xml。要应用的更改是针对WEB.xml的
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
/WEB-INF/applicationContext-security.xml
</param-value>
</context-param>
上下文配置位置
/WEB-INF/applicationContext.xml
/WEB-INF/applicationContext-security.xml
applicationContext.xml看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http auto-config='true'>
<intercept-url pattern="/login.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<intercept-url pattern="/**" access="ROLE_USER" />
<form-login login-page='login.jsp'/>
</http>
</beans:beans>
即使进行了这些更改,名称空间错误也会存在。若要消除此问题,请将以下jar文件添加到WEB-INF/lib,然后添加到库中:
- spring-security-acl-3.1.0.M2.jar
- spring-security-config-3.1.0.M2.jar
- spring-security-core-3.1.0.M2.jar
- spring-security-taglibs-3.1.0.M2.jar
- spring-security-web-3.1.0.M2.jar
在过去的一个小时里,我一直在搜索SO和web,希望这对其他人有所帮助。如果pom中已经存在所有依赖项,请尝试:
1.从“org->springframework”的maven存储库文件夹中删除所有下载的JAR
2.创建一个maven clean build。我今天遇到了非常类似的问题。出于某种原因,
IntelliJ IDEA
在部署应用程序时没有包含Spring Security jar文件。我想我应该同意这里的大多数海报。我使用了Spring Security config jar,它为我解决了这个问题Maven依赖项的ce列表位于:
需要的主要工件有:
@James Jithin-当您在xsi:schemaLocation中有两个不同版本的bean和安全模式时,也会出现这种异常
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd"
在我的例子中,将它们都更改为3.1解决了问题我在部署到Virgo时遇到了这个错误。解决方案是将其添加到我的包导入中:
org.springframework.transaction.config;version="[3.1,3.2)",
我注意到在META-INF下的Spring JAR中有一个Spring.schemas和一个Spring.handlers部分,以及它们指向的类(在本例中为org.springframework.transaction.config.txnamespacehdler)必须导入。我为此挣扎了一段时间,但这些答案都没有帮助。多亏了用户64141的评论,我意识到
spring.handlers
文件存在问题
我正在使用Maven的Shade插件生成一个胖jar,所有的spring.handlers
(和spring.schemas
)文件都被每个spring依赖项覆盖
Maven站点介绍了这个确切的问题,以及如何通过将文件附加在一起来解决这个问题:
我找到了这个解决方案:
将此jar包括在项目中几分钟前,我遇到了相同的问题,我的部署程序集中缺少了“Maven Dependencendies”库。
我通过Eclipse中的“Web部署程序集”部分添加了它。如果添加依赖项还没有解决您的问题,请重新创建WAR存档。在我的例子中,我使用了没有安全Web和安全配置JAR的过时WAR文件我所做的:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
工作完美。更多在pom.xml文件中添加以下依赖项,如果您使用IntelliJ,则将相同的jar添加到WEB-INF->lib文件夹…路径为Project Structure->Atrifacts->Select jar from Available Elements窗格并双击。它将添加到相应的文件夹中
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
org.springframework.security
spring安全配置
3.0.1.1发布
+1用于解决我的问题。有关spring security 3.0代码库重构的更多信息,请访问:Nice link。几个月前我也可以使用它。Bacon再次由SO保存!当尝试仅使用spring security cas
jar时,类似的解决方案也适用。我建议那些无法使用的用户使用此方法找到XML架构命名空间[xxxxx]的Spring NamespaceHandler
问题。我过去有过一次,这对我帮助很大!我在学习Spring pizzashop教程时遇到了这个问题,这是你的完整pom.xml?因为那时你很可能丢失了一个罐子。你几乎必须使用Maven来启动Spring。当你不情愿地这样做时,它仍然不起作用!有人,某个地方在大笑…这个答案帮助我减少了一点挫折感。我刚刚设法让它发挥作用:http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security/spring-security-3.2.xsd
在我的例子中,我的'spring security config'jar不见了。我同意这个评论。我的由于这一原因导致的问题。
xsi:schemaLocation="
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>