从SpringBeanXML到SpringBeanJava类

kx5bkwkv  于 2021-08-20  发布在  Java
关注(0)|答案(1)|浏览(257)

如何在java类中实现这一点?

<bean id="rememberMeFilter" class=
     "org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter">
      <property name="rememberMeServices" ref="rememberMeServices"/>
      <property name="authenticationManager" ref="authenticationManager" />
    </bean>

    <bean id="rememberMeServices" class=
     "org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices">
      <property name="userDetailsService" ref="userService"/>
      <property name="key" value="some-string"/>
    </bean>

    <bean id="rememberMeAuthenticationProvider" class=
     "org.springframework.security.authentication.RememberMeAuthenticationProvider">
      <property name="key" value="some-string"/>
    </bean>

并在java类中禁用自动配置

auto-config="false"
91zkwejq

91zkwejq1#

为了节省时间和避免错误,我将给出不同的建议。而不是使用 @Bean ,您可以在使用时包含整个现有的application context.xml文件 @ImportResource 注解 @Configuration / @SpringBootApplication .
裁判:https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/importresource.html

相关问题