5

基本的な春のセキュリティ設定を試みています。次のように、春のセキュリティxmlにある 3.1.0.RELEASE を使用しています。

<security:http auto-config='true'>
<security:intercept-url pattern="/**" access="ROLE_USER" />
</security:http>

<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="jimi" password="jimispassword" authorities="ROLE_USER,      ROLE_ADMIN" />
<security:user name="bob" password="bobspassword" authorities="ROLE_USER" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>

スタート ページにアクセスすると、次の例外が発生します。ネストされた例外は java.lang.NoSuchFieldError: NULL です。

誰でも私を助けることができますか?

4

2 に答える 2

11

この問題の実際の原因は、spring-security 3.1.0 が古いバージョンの spring を取り込み、サイレント コンフリクトが発生していることにあるようです。私の場合、spring-security-3.1.0.RELEASE は spring-aop、spring-jdbc、spring-tx、および spring-expression 3.0.6 を取り込みましたが、私は spring 3.1.0.RELEASE を使用していました。これらの依存関係を明示的に追加した後、問題はなくなりました。

于 2012-06-14T18:59:29.677 に答える
0

見逃しweb.xmlたようですねorg.springframework.web.context.ContextLoaderListener

次のweb.xml要素が必要です。

<!-- or in your case /WEB-INF/applicationContext-security.xml -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
</context-param>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<servlet>
    <servlet-name>My-Web-SpringProject</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/webmvc-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<filter-mapping>
    <!-- do not change this name! -->
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<!-- it is configured by the parameter contextConfigLocation in the begining -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet-mapping>
    <servlet-name>My-Web-SpringProject</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

正直これはSpring 3.0の構成ですが、3.1でも同じだと思います

于 2012-04-19T06:14:12.263 に答える