首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Spring Bean xml到Spring Bean Java类

从Spring Bean xml到Spring Bean Java类
EN

Stack Overflow用户
提问于 2021-07-08 18:23:13
回答 1查看 17关注 0票数 0

我如何在Java类中做到这一点?

代码语言:javascript
复制
    <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类中禁用自动配置

代码语言:javascript
复制
    auto-config="false"
EN

回答 1

Stack Overflow用户

发布于 2021-07-08 19:50:34

为了节省时间和避免bug,我将给出一个不同的建议。您可以包含整个现有的应用程序上下文.XML文件,因为它将@ImportResource批注与@Configuration/@SpringBootApplication一起使用,而不是使用@Bean重新定义所有bean。

参考:https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/ImportResource.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68299807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档