Unable to identify authentication-provider user-service-ref in Spring Security

前端 未结 2 760
抹茶落季
抹茶落季 2021-01-25 21:12

I am implementing spring security in my project

In my DAO class I am defining the loadUserByUsername

my class is like

UserDAOImpl.java

@         


        
相关标签:
2条回答
  • 2021-01-25 21:38

    Typically beans that are component scanned are camel-cased starting with a lowercase character so the bean would exist in the application context as userDAOImpl (not UserDAOImpl)

    change your spring-security.xml snippet to

    <authentication-manager>
        <authentication-provider user-service-ref="userDAOImpl">
      </authentication-provider>
    </authentication-manager>
    

    Hope this works for you.

    0 讨论(0)
  • 2021-01-25 21:46

    phew... got it working.

    Moved

    <context:component-scan base-package="app.com,app.com.controller,app.com.dao,app.com.service,app.com.model"/>
    
        <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
                p:basename="messages"/>
    

    from dispatcher-servlet to application-context.xml

    @Service("userDAOImpl") annotation on class name

    Would anyone care to tell why it started working?

    0 讨论(0)
提交回复
热议问题