Let's say I have a spring profile that is specific to a particular operating system:
spring:
profiles: mac
cloud:
zookeeper:
discovery:
preferIpAddress: false
instanceHost: docker.for.mac.localhost
Is there some way to automatically enable a spring profile based on the current operating system?
So in my case, I want the above profile to automatically become active if it is on a Darwin os.
Maybe there is some way to do it with system properties? In this case, I want the mac profile to be active if os.name contains "Darwin"?
Any ideas?
something like this would work for you? Of course you should adjust the condition.
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(DemoApplication.class);
if (System.getProperty("os.name").contains("darwin")) {
app.setAdditionalProfiles("mac");
}
app.run(args);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With