views:

44

answers:

1

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
{
+2  A: 

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:

seanizer
thanks for helping a relative spring n00b. Now that it is finding my beans, it won't find my PersistenceContext, which I'm magically wiring in using @PersistenceContext EntityManager em;any quick thoughts on that or should I make that a separate question?
digitaljoel
that should usually work automatically. If it doesn't, please make it an extra question and provide some code (the xml context and the bean)
seanizer
Thanks again seanizer. I'll create a new question for that.
digitaljoel