本文整理匯總了Java中org.springframework.boot.builder.SpringApplicationBuilder.build方法的典型用法代碼示例。如果您正苦於以下問題:Java SpringApplicationBuilder.build方法的具體用法?Java SpringApplicationBuilder.build怎麽用?Java SpringApplicationBuilder.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.boot.builder.SpringApplicationBuilder
的用法示例。
在下文中一共展示了SpringApplicationBuilder.build方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: before
import org.springframework.boot.builder.SpringApplicationBuilder; //導入方法依賴的package包/類
@Override
protected void before() throws Throwable {
final SpringApplicationBuilder builder = new SpringApplicationBuilder(LocalTestSkipperServer.class);
if (this.configLocations != null && this.configLocations.length > 0) {
builder.properties(
String.format("spring.config.location:%s", StringUtils.arrayToCommaDelimitedString(this.configLocations))
);
}
if (this.configNames != null && this.configNames.length > 0) {
builder.properties(
String.format("spring.config.name:%s", StringUtils.arrayToCommaDelimitedString(this.configNames))
);
}
this.app = builder.build();
configurableApplicationContext = app.run(
new String[] { "--server.port=0" });
Collection<Filter> filters = configurableApplicationContext.getBeansOfType(Filter.class).values();
mockMvc = MockMvcBuilders.webAppContextSetup((WebApplicationContext) configurableApplicationContext)
.addFilters(filters.toArray(new Filter[filters.size()])).build();
skipperPort = configurableApplicationContext.getEnvironment().resolvePlaceholders("${server.port}");
}