下面列出了org.springframework.boot.SpringApplication#setAdditionalProfiles ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void testWithLocalDeployer() throws Exception {
SpringApplication app = new SpringApplication(PartitionedBatchJobApplication.class);
app.setAdditionalProfiles("master");
Properties properties = new Properties();
properties.setProperty("spring.datasource.url", DATASOURCE_URL);
properties.setProperty("spring.datasource.username", DATASOURCE_USER_NAME);
properties.setProperty("spring.datasource.driverClassName", DATASOURCE_DRIVER_CLASS_NAME);
properties.setProperty("spring.cloud.deployer.local.use-spring-application-json", "false");
app.setDefaultProperties(properties);
app.run();
Page<TaskExecution> taskExecutions = this.taskExplorer
.findAll(PageRequest.of(0, 10));
assertThat(taskExecutions.getTotalElements()).as("Five rows are expected")
.isEqualTo(5);
assertThat(this.taskExplorer
.getTaskExecutionCountByTaskName("PartitionedBatchJobTask"))
.as("Only One master is expected").isEqualTo(1);
for (TaskExecution taskExecution : taskExecutions) {
assertThat(taskExecution.getExitCode()
.intValue()).as("return code should be 0").isEqualTo(0);
}
}
MongoDbFixture() {
SpringApplication application = new SpringApplication();
application.addPrimarySources(Collections.singletonList(MongoDbApplication.class));
application.setAdditionalProfiles("jpa");
application.setLazyInitialization(true);
this.context = application.run();
MongoOperations operations = context.getBean(MongoOperations.class);
operations.dropCollection(Book.class);
IntStream.range(0, Constants.NUMBER_OF_BOOKS) //
.mapToObj(it -> new Book("title" + it, it)) //
.forEach(operations::save);
}
/**
* If no profile has been configured, set by default the "dev" profile.
*/
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);
}
}
/**
* If no profile has been configured, set by default the "dev" profile.
*/
private static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) {
if (!source.containsProperty("spring.profiles.active") &&
!System.getenv().containsKey("SPRING_PROFILES_ACTIVE")) {
app.setAdditionalProfiles(Constants.SPRING_PROFILE_DEVELOPMENT);
}
}
/**
* If no profile has been configured, set by default the "dev" profile.
*/
private static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) {
if (!source.containsProperty("spring.profiles.active") &&
!System.getenv().containsKey("SPRING_PROFILES_ACTIVE")) {
app.setAdditionalProfiles(Constants.SPRING_PROFILE_DEVELOPMENT);
}
}
/**
* If no profile has been configured, set by default the "dev" profile.
*/
private static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) {
if (!source.containsProperty("spring.profiles.active") &&
!System.getenv().containsKey("SPRING_PROFILES_ACTIVE")) {
app.setAdditionalProfiles(Constants.SPRING_PROFILE_DEVELOPMENT);
}
}
/**
* This is the initializing method when running ParaServer as executable JAR (or WAR),
* from the command line: java -jar para.jar.
* @param args command line arguments array (same as those in {@code void main(String[] args)} )
* @param sources the application classes that will be scanned
*/
public static void runAsJAR(String[] args, Class<?>... sources) {
// entry point (JAR)
SpringApplication app = new SpringApplication(sources);
app.setAdditionalProfiles(Config.ENVIRONMENT);
app.setWebApplicationType(WebApplicationType.SERVLET);
app.setBannerMode(Banner.Mode.OFF);
if (Config.getConfigBoolean("pidfile_enabled", true)) {
app.addListeners(new ApplicationPidFileWriter(Config.PARA + "_" + getServerPort() + ".pid"));
}
initialize(getCoreModules());
app.run(args);
}
/**
* If no profile has been configured, set by default the "dev" profile.
*/
private static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) {
if (!source.containsProperty("spring.profiles.active") &&
!System.getenv().containsKey("SPRING_PROFILES_ACTIVE")) {
app.setAdditionalProfiles(Constants.SPRING_PROFILE_DEVELOPMENT);
}
}
/**
* If no profile has been configured, set by default the "dev" profile.
*/
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) {
SpringApplication app = new SpringApplication(OrderTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(CustomerTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(CustomerTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(OrderTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}
public static void main(String[] args) {
SpringApplication application = new SpringApplication(ProfilesApplication.class);
application.setAdditionalProfiles("baz");
application.run(args);
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(OrderTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(ShippingTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(InvoiceTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(InvoiceTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(OrderTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(CatalogTestApp.class);
app.setAdditionalProfiles("test");
app.run(args);
}