When using Spring Boot 1.X, you can update the System Property with an additional profile name and handle all the boolean logic before your SpringApplication.run. If it qualifies, you would append the profile name to the active profiles. If it doesn't, you would not change anything.
This is a very basic check but you can add more rigorous profile validation, such as null check and actually splitting the profiles list.
String profile = System.getProperty("spring.profiles.active");
if(!profile.contains("test") && !profile.contains("local")) {
System.setProperty("spring.profiles.active", profile + ",notdev");
}
If you are using Spring Boot 2.0, you can use addAdditionalProfiles to add the profile (don't have a SB2 app so I can't test this but I assume it just adds it to the System properties list).
String profile = System.getProperty("spring.profiles.active");
if(!profile.contains("test") && !profile.contains("local")) {
SpringApplication.addAdditionalProfiles("notdev");
}
Then your annotation can be:
@Profile({"notdev"})