Do i need to declare bean in spring security xml if i use annotation
this is my spring security file
<!-- Declare an authentication-manager to use a custom userDetailsService -->
<security:authentication-manager>
<security:authentication-provider user-service-ref="customUserDetailsService">
</security:authentication-provider>
</security:authentication-manager>
<!开发者_Python百科-- Use a Md5 encoder since the user's passwords are stored as Md5 in the database -->
<bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" id="passwordEncoder"/>
<!-- A custom service where Spring will retrieve users and their corresponding access levels -->
<bean id="customUserDetailsService" class="com.vaannila.service.CustomUserDetailsService" />
This is running fine , i want to ask that if i use @Service
on CustomUserDetailsService then can i delete the bean line form xml file and spring security will read the bean from annotation or not
Yes, assuming you don't move the bean to a different ApplicationContext (this is directly related to the location of your <context:component-scan.../>
declaration).
Conversely, you can @Autowired
many/most of the Spr Sec beans which are identified by a specific id
.
精彩评论