简体   繁体   中英

Spring security configuration using annotation configured beans

I'm attempting to configure spring security to use a service I implemented for authentication. My services and entity manager and all that are configured with annotations. I don't want to move all of the service, dao, and entity manager configuration into XML. How can I get the authentication-provider configuration to reference a service bean that is only configured through annotations?

Here is the configuration in the xml

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

And here is the definition of the service

@Configurable
@Service( value = "userService" )
public class UserServiceImpl
        extends BaseDataServiceAbstract<User, Long>
        implements UserService
{

If you just add this to your XML:

<context:component-scan base-package="org.package.where.your.beans.are"/>

Spring should pick up all your annotation-configured beans and let you autowire them into the security configuration.

Reference:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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