繁体   English   中英

解决XSD模式的Spring错误

[英]Spring error in resolving xsd schema

我正在尝试使用Spring Security模块,但是收到有关安全xsd文件的XML验证错误。

这是spring-security.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.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/security http://www.springframework.org/schema/security/spring-security.xsd">



    <!--  Security....................................... -->

    <security:http security="none" pattern="/resources/**"/>
    <security:http auto-config="true" use-expressions="true" >
        <security:intercept-url pattern="/admin/**" access="hasRole('Admin')" />
        <security:logout logout-success-url="/welcome" logout-url="/logout" />
        <security:form-login login-page="/login"
            default-target-url="/welcome"
            username-parameter="username"
            password-parameter="hashPwd" 
            authentication-failure-url="/login?error"
            />
    </security:http>


    <security:authentication-manager>
       <security:authentication-provider user-service-ref="controlloUtente">
         <security:password-encoder hash="bcrypt" />  
      </security:authentication-provider>
    </security:authentication-manager>

</beans:beans>

这是我得到的异常(我显然检查了文件是否存在!):

19/06/2015 12:32:38 - WARN  - (SimpleSaxErrorHandler.java:48) - Ignored XML validation warning
org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 58; schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/security/spring-security.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:99)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:433)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:347)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4166)

我在代理后面,但是我配置了它,另一个xsd得到解决,所以我不知道发生了什么。

也许这段代码会有所帮助:

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

<security:http auto-config="true">

    <security:intercept-url pattern="/login.do"
        access="IS_AUTHENTICATED_ANONYMOUSLY" />
    <security:intercept-url pattern="/logout.do"
        access="IS_AUTHENTICATED_ANONYMOUSLY" />
    <security:intercept-url pattern="/fail2login.do"
        access="IS_AUTHENTICATED_ANONYMOUSLY" />
    <security:intercept-url pattern="/json/*.do"
        access="IS_AUTHENTICATED_ANONYMOUSLY" />

    <security:intercept-url pattern="/*" access="ROLE_ADMIN" />
    <security:form-login login-page="/login.do"
        default-target-url="/home.do" authentication-failure-url="/fail2login.do" />

    <security:session-management>
        <security:concurrency-control
            max-sessions="1" />
    </security:session-management>
    <security:logout logout-success-url="/logout.do"
        delete-cookies="JSESSIONID" invalidate-session="true" />
</security:http>

<security:authentication-manager>
    <security:authentication-provider>
        <security:jdbc-user-service
            data-source-ref="dataSource"
            users-by-username-query="select userName, password, status from User where userName=?"
            authorities-by-username-query="select us.userName, ur.userRoleName from User us, UserRole ur   
            where ur.userName =?  " />
    </security:authentication-provider>
</security:authentication-manager>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM