spring-security.xml中的构造函数arg错误

时间:2014-09-18 08:06:58

标签: spring-mvc spring-security sha password-encryption

我使用spring security作为我的登录页面。在数据库中,用户密码是使用sha-password encoder存储的。现在我想在spring-security.xml中使用相同的内容。我试过这个

<beans:bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder">
 <constructor-arg value="256"/>
 </beans:bean>


    <authentication-manager>  
  <authentication-provider> 
    <password-encoder ref="passwordEncoder"/>
  <jdbc-user-service data-source-ref="dataSource"
          users-by-username-query=
            "select email,password, 'true' as enabled from user_login where email=? limit 1"
          authorities-by-username-query=
            "select email, role from user_roles where email =?  " />
      </authentication-provider>
      </authentication-manager>  
 </beans:beans>

我得到了错误  

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'constructor-arg'.
    - Security namespace does not support decoration of element [constructor-arg]
    - Configuration problem: Security namespace does not support decoration of element.

任何人都可以帮助我。

1 个答案:

答案 0 :(得分:2)

constructor-arg元素不在安全名称空间中,而是在beans名称空间中。所以在你的情况下,使用:

<beans:constructor-arg value="256"/>