开发者

Do i need to declare bean in spring security xml if i use annotation

开发者 https://www.devze.com 2023-02-19 15:33 出处:网络
this is my spring security file <!-- Declare an authentication-manager to use a custom userDetailsService -->

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消