这是我的春季安全档案
<!-- 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>
<!-- 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" />
运行正常,我想问一下,如果我在CustomUserDetailsService上使用@Service
,那么我可以删除bean行形式的xml文件,spring security是否会从注释读取bean
答案 0 :(得分:0)
是的,假设您没有将bean移动到其他ApplicationContext(这与您的<context:component-scan.../>
声明的位置直接相关)。
相反,您可以@Autowired
许多/大多数由特定id
标识的Spr Sec bean。