小编lax*_*xmi的帖子

如何根据属性文件中的属性值实例化@configuration bean

我有两个带有注释的类/bean @Configuration,我必须根据属性文件中的值进行实例化。

远程服务器1.java

@Configuration
public class RemoteServer1 {
    //some authentication logic goes here
}
Run Code Online (Sandbox Code Playgroud)

远程服务器2.java

@Configuration
public class RemoteServer2 {
    //some authentication logic goes here
}
Run Code Online (Sandbox Code Playgroud)

应用程序属性

remote.server.location=RemoteServer1
Run Code Online (Sandbox Code Playgroud)

现在我想实例化@Configuration与属性文件中的值匹配的类/bean。

spring spring-boot

2
推荐指数
1
解决办法
3427
查看次数

标签 统计

spring ×1

spring-boot ×1