Spring - Multiple Profiles active

后端 未结 4 822
遇见更好的自我
遇见更好的自我 2020-12-24 08:08

I basically have a bean in Spring that I wanted to activate only when 2 profiles are active. Basically, it would be like:

@Profile({\"Tomcat\", \"Linux\"})
p         


        
4条回答
  •  滥情空心
    2020-12-24 08:18

    The first profile is on the Top level. The second I checked like this:

    @Autowired
    private Environment env;
    ...
    final boolean isMyProfile = Arrays.stream(env.getActiveProfiles()).anyMatch("MyProfile"::equals);
    

提交回复
热议问题