你可以将bean注入移动到配置中,如下所示:
@Configurationpublic class AppConfig { @Bean public MyService getMyService() { if(windows) return new MyServiceWin(); else return new MyServiceLnx(); }}或者,你可以使用配置文件
windows和linux,然后使用
@Profile注释(如
@Profile(
"linux")或
@Profile("windows"))为服务实现添加注释,并为你的应用程序提供此配置文件之一。


