[英]from Spring Bean xml to Spring Bean Java classes
How can I do this in Java classes?我怎样才能在 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>
And also disable auto-configuration in Java classes并且还禁用 Java 类中的自动配置
auto-config="false"
To save time and avoid bugs, I will give a different suggestion.为了节省时间和避免bug,我会给出不同的建议。 Instead of re-defining all beans using
@Bean
, you can include the whole existing application context .XML file(s) as it is using @ImportResource
annotation with @Configuration
/ @SpringBootApplication
.您可以包含整个现有的应用程序上下文 .XML 文件,而不是使用
@Bean
重新定义所有 bean,因为它使用带有@Configuration
/ @SpringBootApplication
@ImportResource
注释。
Ref: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/ImportResource.html参考: https : //docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/ImportResource.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.