Error creating bean with name 'org.springframework.security.filterChains' Spring + Hibernate + UserDetailService

后端 未结 3 703
有刺的猬
有刺的猬 2021-01-02 03:44

I just started to learn Spring Security and have some trouble. I want to configure User login on page with password and username which stored in database during registration

相关标签:
3条回答
  • 2021-01-02 04:21
     <security:http auto-config="true">
    

    replace this section with the following:

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

    Note:

    As a side note i see from the code and from comment i doubt you have injected SessionFactory from GuestBookDAOImpl, thats causes NPE upon method call on the DAO layer. Inject it either from xml config or annotations.

    0 讨论(0)
  • 2021-01-02 04:22

    Bean creation error for "org.springframework.security.filterChains" comes when you are using spring version higher than 3.1 and have not added dependencies manually for spring-aop, spring-jdbc, spring-tx and spring-expressions in you POM.xml.

    Reason : If don't do so, maven automatically downloads older version jars (3.0.x) for these artifacts which conflict with newer version spring security jars.

    0 讨论(0)
  • 2021-01-02 04:30

    use use-expressions="true" along with auto-config="true"

    <security:http auto-config="true" use-expressions="true">       
           <security:intercept-url pattern="/user/*" access="hasRole('ROLE_USER')"/> </security:http>
    
    0 讨论(0)
提交回复
热议问题