org.springframework.boot.SpringApplication Java Examples
The following examples show how to use
org.springframework.boot.SpringApplication.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WaggleDance.java From waggle-dance with Apache License 2.0 | 7 votes |
public static void main(String[] args) throws Exception { // below is output *before* logging is configured so will appear on console logVersionInfo(); int exitCode = -1; try { SpringApplication application = new SpringApplicationBuilder(WaggleDance.class) .properties("spring.config.location:${server-config:null},${federation-config:null}") .properties("server.port:${endpoint.port:18000}") .registerShutdownHook(true) .build(); exitCode = SpringApplication.exit(registerListeners(application).run(args)); } catch (BeanCreationException e) { Throwable mostSpecificCause = e.getMostSpecificCause(); if (mostSpecificCause instanceof BindException) { printHelp(((BindException) mostSpecificCause).getAllErrors()); } if (mostSpecificCause instanceof ConstraintViolationException) { logConstraintErrors(((ConstraintViolationException) mostSpecificCause)); } throw e; } if (exitCode != 0) { throw new Exception("Waggle Dance didn't exit properly see logs for errors, exitCode=" + exitCode); } }
Example #2
Source File: HbaseSchemaManager.java From pinpoint with Apache License 2.0 | 6 votes |
public static void main(String[] args) { ProgramCommand programCommand = ProgramCommand.parseArgs(args); if (programCommand == ProgramCommand.EMPTY) { printHelp(); return; } Command command = Command.fromValue(programCommand.getCommand()); if (command == null) { LOGGER.info(Markers.TERMINAL, "'{}' is not a valid command.", programCommand.getCommand()); printHelp(); return; } if (command == Command.HELP) { printHelp(); return; } SpringApplication application = new SpringApplication(HbaseSchemaManager.class); application.setBannerMode(Banner.Mode.OFF); application.run(args); }
Example #3
Source File: MongoDbFixture.java From spring-data-dev-tools with Apache License 2.0 | 6 votes |
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); }
Example #4
Source File: FailureAnalyzerAppIntegrationTest.java From tutorials with MIT License | 6 votes |
@Test public void givenBeanCreationErrorInContext_whenContextLoaded_thenFailureAnalyzerLogsReport() { try { SpringApplication.run(FailureAnalyzerApplication.class); } catch (BeanCreationException e) { Collection<String> allLoggedEntries = ListAppender.getEvents() .stream() .map(ILoggingEvent::getFormattedMessage) .collect(Collectors.toList()); assertThat(allLoggedEntries).anyMatch(entry -> entry.contains(EXPECTED_ANALYSIS_DESCRIPTION_TITLE)) .anyMatch(entry -> entry.contains(EXPECTED_ANALYSIS_DESCRIPTION_CONTENT)) .anyMatch(entry -> entry.contains(EXPECTED_ANALYSIS_ACTION_TITLE)) .anyMatch(entry -> entry.contains(EXPECTED_ANALYSIS_ACTION_CONTENT)); return; } throw new IllegalStateException("Context load should be failing due to a BeanCreationException!"); }
Example #5
Source File: LocalDataflowResource.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Override protected void before() { originalDataflowServerPort = System.getProperty(DATAFLOW_PORT_PROPERTY); this.dataflowServerPort = SocketUtils.findAvailableTcpPort(); logger.info("Setting Dataflow Server port to " + this.dataflowServerPort); System.setProperty(DATAFLOW_PORT_PROPERTY, String.valueOf(this.dataflowServerPort)); originalConfigLocation = System.getProperty("spring.config.additional-locationn"); if (!StringUtils.isEmpty(configurationLocation)) { final Resource resource = new PathMatchingResourcePatternResolver().getResource(configurationLocation); if (!resource.exists()) { throw new IllegalArgumentException(String.format("Resource 'configurationLocation' ('%s') does not exist.", configurationLocation)); } System.setProperty("spring.config.additional-location", configurationLocation); } app = new SpringApplication(TestConfig.class); configurableApplicationContext = (WebApplicationContext) app.run(new String[] { "--spring.cloud.kubernetes.enabled=false", "--" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.STREAMS_ENABLED + "=" + this.streamsEnabled, "--" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.TASKS_ENABLED + "=" + this.tasksEnabled, "--" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.SCHEDULES_ENABLED + "=" + this.schedulesEnabled, "--spring.cloud.skipper.client.serverUri=http://localhost:" + this.skipperServerPort + "/api" }); skipperClient = configurableApplicationContext.getBean(SkipperClient.class); LauncherRepository launcherRepository = configurableApplicationContext.getBean(LauncherRepository.class); launcherRepository.save(new Launcher("default", "local", new LocalTaskLauncher(new LocalDeployerProperties()))); Collection<Filter> filters = configurableApplicationContext.getBeansOfType(Filter.class).values(); mockMvc = MockMvcBuilders.webAppContextSetup(configurableApplicationContext) .addFilters(filters.toArray(new Filter[filters.size()])).build(); dataflowPort = configurableApplicationContext.getEnvironment().resolvePlaceholders("${server.port}"); }
Example #6
Source File: FunctionDeployerTests.java From spring-cloud-function with Apache License 2.0 | 5 votes |
@Test public void testWithMainAndStartClassAndSpringConfigurationJavax() throws Exception { String[] args = new String[] { "--spring.cloud.function.location=target/it/bootapp-with-javax/target/bootapp-with-javax-1.0.0.RELEASE-exec.jar", "--spring.cloud.function.function-name=uppercase" }; ApplicationContext context = SpringApplication.run(DeployerApplication.class, args); FunctionCatalog catalog = context.getBean(FunctionCatalog.class); Function<Message<byte[]>, Message<byte[]>> function = catalog.lookup("uppercase", "application/json"); Message<byte[]> result = function .apply(MessageBuilder.withPayload("\"[email protected]\"".getBytes(StandardCharsets.UTF_8)).build()); assertThat(new String(result.getPayload(), StandardCharsets.UTF_8)).isEqualTo("\"[email protected]\""); }
Example #7
Source File: DefaultProfileUtil.java From tutorials with MIT License | 5 votes |
/** * Set a default to use when no profile is configured. * * @param app the Spring application */ public static void addDefaultProfile(SpringApplication app) { Map<String, Object> defProperties = new HashMap<>(); /* * The default profile to use when no other profiles are defined * This cannot be set in the <code>application.yml</code> file. * See https://github.com/spring-projects/spring-boot/issues/1219 */ defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); app.setDefaultProperties(defProperties); }
Example #8
Source File: OpenAuthServerApp.java From open-capacity-platform with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // 固定端口启动 // SpringApplication.run(OpenAuthServerApp.class, args); //随机端口启动 SpringApplication app = new SpringApplication(OpenAuthServerApp.class); app.addListeners(new PortApplicationEnvironmentPreparedEventListener()); app.run(args); }
Example #9
Source File: RibbonRetrySuccessIntegrationTest.java From tutorials with MIT License | 4 votes |
private static ConfigurableApplicationContext startApp(int port) { return SpringApplication.run(RibbonWeatherServiceApp.class, "--server.port=" + port, "--successful.call.divisor=3"); }
Example #10
Source File: MetronRestApplication.java From metron with Apache License 2.0 | 4 votes |
public static void main(String[] args) { ParserIndex.reload(); SpringApplication.run(MetronRestApplication.class, args); }
Example #11
Source File: CorsWebFilterApplication.java From tutorials with MIT License | 4 votes |
public static void main(String[] args) { SpringApplication app = new SpringApplication(CorsWebFilterApplication.class); app.setDefaultProperties(Collections.singletonMap("server.port", "8083")); app.run(args); }
Example #12
Source File: App.java From springcloud-course with GNU General Public License v3.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(App.class, args); }
Example #13
Source File: ShopServiceConsumerApplication.java From spring-boot-demo-all with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(ShopServiceConsumerApplication.class, args); }
Example #14
Source File: MallUserApplication.java From mall with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(MallUserApplication.class, args); }
Example #15
Source File: SpringBootTmplFreemarkApplication.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 4 votes |
public static void main(String[] args) { SpringApplication.run(SpringBootTmplFreemarkApplication.class, args); }
Example #16
Source File: JpaUtilTests.java From linq with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { SpringApplication.run(JpaUtilTests.class, args); }
Example #17
Source File: SpringDocTestApp.java From springdoc-openapi with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(SpringDocTestApp.class, args); }
Example #18
Source File: Main.java From JSF-on-Spring-Boot with GNU General Public License v3.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(Main.class, args); }
Example #19
Source File: PolymerResourceApplication.java From spring-polymer-demo with Artistic License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(PolymerResourceApplication.class, args); }
Example #20
Source File: CalculatorApplication.java From Continuous-Delivery-with-Docker-and-Jenkins-Second-Edition with MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(CalculatorApplication.class, args); }
Example #21
Source File: ServiceAApplication.java From code with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(ServiceAApplication.class, args); }
Example #22
Source File: OpsCenterApplication.java From opscenter with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(OpsCenterApplication.class, args); }
Example #23
Source File: DemoApplication.java From mcloud with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); }
Example #24
Source File: Application.java From spring-jwt-gateway with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(Application.class, args); }
Example #25
Source File: ActivemqConsumeApplication.java From onetwo with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(ActivemqConsumeApplication.class, args); }
Example #26
Source File: Bucket4jInfinispanApplication.java From spring-cloud-zuul-ratelimit with Apache License 2.0 | 4 votes |
public static void main(String... args) { SpringApplication.run(Bucket4jInfinispanApplication.class, args); }
Example #27
Source File: AdminServiceApplication.java From seckill with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(AdminServiceApplication.class, args); }
Example #28
Source File: RSocketBrokerHttpGatewayApp.java From alibaba-rsocket-broker with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(RSocketBrokerHttpGatewayApp.class, args); }
Example #29
Source File: SpacedLogApplication.java From spring-cloud-formula with Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(SpacedLogApplication.class, args); }
Example #30
Source File: BlogmaniaApplication.java From Spring-Boot-2-Fundamentals with MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(BlogmaniaApplication.class, args); }