Java Code Examples for org.springframework.boot.SpringApplication
The following examples show how to use
org.springframework.boot.SpringApplication. These examples are extracted from open source projects.
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 Project: tutorials Source File: FailureAnalyzerAppIntegrationTest.java License: 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 2
Source Project: pinpoint Source File: HbaseSchemaManager.java License: 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 Project: waggle-dance Source File: WaggleDance.java License: Apache License 2.0 | 6 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 4
Source Project: spring-data-dev-tools Source File: MongoDbFixture.java License: 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 5
Source Project: spring-cloud-function Source File: FunctionDeployerTests.java License: 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 6
Source Project: tutorials Source File: DefaultProfileUtil.java License: 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 7
Source Project: open-capacity-platform Source File: OpenAuthServerApp.java License: 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 8
Source Project: spring-cloud-dataflow Source File: LocalDataflowResource.java License: 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 9
Source Project: SpringBootLearn Source File: SpringbootThymeleafApplication.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(SpringbootThymeleafApplication.class, args); }
Example 10
Source Project: spring-boot-tutorial Source File: SpringBootSchedulerApplication.java License: Creative Commons Attribution Share Alike 4.0 International | 4 votes |
public static void main(String[] args) { SpringApplication.run(SpringBootSchedulerApplication.class, args); }
Example 11
Source Project: EasyReport Source File: WebApplication.java License: Apache License 2.0 | 4 votes |
public static void main(final String[] args) { SpringApplication.run(WebApplication.class, args); }
Example 12
Source Project: x-pipe Source File: AppTest.java License: Apache License 2.0 | 4 votes |
@Test public void startAppTest(){ SpringApplication.run(AppTest.class); }
Example 13
Source Project: monolith-to-microservices Source File: GatewayApplication.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(GatewayApplication.class, args); }
Example 14
Source Project: HIS Source File: ServiceSmsApplication.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(ServiceSmsApplication.class,args); }
Example 15
Source Project: spring-5-examples Source File: App.java License: MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(App.class, args); }
Example 16
Source Project: Spring-Security-Third-Edition Source File: CalendarApplication.java License: MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(CalendarApplication.class, args); }
Example 17
Source Project: spring-boot-demo Source File: AncFeignConsumerApplication.java License: MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(AncFeignConsumerApplication.class, args); }
Example 18
Source Project: cf-butler Source File: AppInit.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(AppInit.class, args); }
Example 19
Source Project: shardingsphere Source File: ExampleMain.java License: Apache License 2.0 | 4 votes |
public static void main(final String[] args) throws SQLException { try (ConfigurableApplicationContext applicationContext = SpringApplication.run(ExampleMain.class, args)) { ExampleExecuteTemplate.run(applicationContext.getBean(ExampleService.class)); } }
Example 20
Source Project: wingtips Source File: VerifySampleEndpointsComponentTest.java License: Apache License 2.0 | 4 votes |
@AfterClass public static void afterClass() { SpringApplication.exit(serverAppContext); }
Example 21
Source Project: spring-boot-demo Source File: SpringBootDemoOrmMybatisMapperPageApplication.java License: MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(SpringBootDemoOrmMybatisMapperPageApplication.class, args); }
Example 22
Source Project: lite-tracer Source File: Bootstrap.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(Bootstrap.class, args); LOGGER.info("tracer-demo-B启动完成......"); }
Example 23
Source Project: tutorial Source File: Application.java License: MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(Application.class, args); }
Example 24
Source Project: tutorials Source File: ReactiveWebSocketApplication.java License: MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(ReactiveWebSocketApplication.class, args); }
Example 25
Source Project: java-persistence-frameworks-comparison Source File: DbTestsApplication.java License: MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(DbTestsApplication.class, args); }
Example 26
Source Project: microservice-consul Source File: CatalogTestApp.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication app = new SpringApplication(CatalogTestApp.class); app.setAdditionalProfiles("test"); app.run(args); }
Example 27
Source Project: spring-cloud-study Source File: Application.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(Application.class, args); }
Example 28
Source Project: tutorials Source File: GraylogDemoApplication.java License: MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(GraylogDemoApplication.class, args); LOG.info("Hello from Spring Boot"); }
Example 29
Source Project: blog_demos Source File: ConfigdemoApplication.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { SpringApplication.run(ConfigdemoApplication.class, args); }
Example 30
Source Project: Hands-On-Reactive-Programming-with-Reactor Source File: ReactorMain.java License: MIT License | 4 votes |
public static void main(String[] args) { SpringApplication.run(ReactorMain.class, args); }