@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication application = new SpringApplication(MyApplication.class);
application.setAdditionalProfiles("dev","animal_dev");
application.run(args);
}
}
@SpringBootApplication
@ComponentScan // Using a root package also allows the @ComponentScan annotation to be used without needing to specify a basePackage attribute
public class SpringBootConfig {
public static void main(String[] args) throws Exception {
SpringApplication springApplication=new SpringApplication(SpringBootConfig.class);
String[] profiles= new String[]{"production","production-extra"}; // array of profiles, create array of one profile in case single profile
springApplication.setAdditionalProfiles(profiles); // set active profile, We can write condition here based on requirements
springApplication.run(args); // run spring boot application
}
}
public static void main(String[] args) throws UnknownHostException {
SpringApplication app = new SpringApplication(App.class);
SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args);
if (!source.containsProperty("spring.profiles.active") &&
!System.getenv().containsKey("SPRING_PROFILES_ACTIVE")) {
app.setAdditionalProfiles("production");
}
...
}
@SpringBootApplication
public class ExampleMain {
public static void main(String[] args) {
System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "prod");
SpringApplication sa = new SpringApplication(ExampleMain.class);
sa.setAdditionalProfiles("remote","live");
sa.run(args);
}
}
@SpringBootApplication
public class ExampleMain2 {
public static void main(String[] args) {
ConfigurableEnvironment environment = new StandardEnvironment();
environment.setActiveProfiles("dev");
SpringApplication sa = new SpringApplication(ExampleMain2.class);
sa.setEnvironment(environment);
sa.setAdditionalProfiles("remote","live");
sa.run(args);
}
}
public static void main(String[] args) {
SpringApplication application = new SpringApplication(Application.class);
application.setAdditionalProfiles("local");
try {
BootShim bs = new BootShim(args, application.run(args));
bs.run();
} catch (RuntimeException e) {
throw e;
} finally {
HandlerUtils.flushAllHandlers(Logger.getLogger(""));
}
}
public static void main(String[] args) {
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
String profiles = System.getProperty("spring.profiles.active", "");
log.info("requested profiles {}", profiles);
SpringApplication application = new SpringApplication(SpringBootInitializer.class, DataSourceConfiguration.class, WebSecurityConfig.class, MvcConfiguration.class);
application.setAdditionalProfiles(Initializer.PROFILE_SPRING_BOOT);
ConfigurableApplicationContext applicationContext = application.run(args);
ConfigurableEnvironment environment = applicationContext.getEnvironment();
log.info("active profiles: {}", String.join(", ", environment.getActiveProfiles()));
if (System.getProperty("startDBManager") != null) {
Class<?> cls;
try {
cls = ClassUtils.getClass("org.hsqldb.util.DatabaseManagerSwing");
MethodUtils.invokeStaticMethod(cls, "main", new Object[] { new String[] { "--url", "jdbc:hsqldb:mem:alfio", "--noexit" } });
} catch (ReflectiveOperationException e) {
log.warn("error starting db manager", e);
}
}
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(ApplicationStarter.class);
app.setAdditionalProfiles();
app.setBannerMode(Banner.Mode.LOG);
app.run(args);
}
protected static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) {
if ((System.getProperty("spring.profiles.active") == null)
&& !source.containsProperty("spring.profiles.active")
&& !System.getenv().containsKey("SPRING_PROFILES_ACTIVE")) {
app.setAdditionalProfiles(Constants.SPRING_PROFILE_DEVELOPMENT);
}
}
public static void main(String[] args) {
((ch.qos.logback.classic.Logger) logger).setLevel(ch.qos.logback.classic.Level.TRACE);
SpringApplication app = new SpringApplication(new Object[]{ScooldServer.class});
initConfig();
app.setAdditionalProfiles(Config.ENVIRONMENT);
app.setWebEnvironment(true);
app.run(args);
}