use of org.springframework.boot.SpringApplication in project jhipster-sample-app-hazelcast by jhipster.
the class JhipsterHazelcastSampleApplicationApp method main.
/**
* Main method, used to run the application.
*
* @param args the command line arguments
*/
public static void main(String[] args) {
SpringApplication app = new SpringApplication(JhipsterHazelcastSampleApplicationApp.class);
DefaultProfileUtil.addDefaultProfile(app);
Environment env = app.run(args).getEnvironment();
String protocol = "http";
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https";
}
String hostAddress = "localhost";
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
} catch (Exception e) {
log.warn("The host name could not be determined, using `localhost` as fallback");
}
log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, hostAddress, env.getProperty("server.port"), env.getActiveProfiles());
}
use of org.springframework.boot.SpringApplication in project x-pipe by ctripcorp.
the class KeeperContainerApplication method main.
public static void main(String[] args) throws Exception {
SpringApplication application = new SpringApplication(KeeperContainerApplication.class);
application.setRegisterShutdownHook(false);
final ConfigurableApplicationContext context = application.run(args);
final ComponentRegistry registry = initComponentRegistry(context);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
try {
logger.info("[run][shutdown][stop]");
registry.stop();
} catch (Exception e) {
logger.error("[run][shutdown][stop]", e);
}
try {
logger.info("[run][shutdown][dispose]");
registry.dispose();
} catch (Exception e) {
logger.error("[run][shutdown][dispose]", e);
}
try {
logger.info("[run][shutdown][destroy]");
registry.destroy();
} catch (Exception e) {
logger.error("[run][shutdown][destroy]", e);
}
}
}));
}
use of org.springframework.boot.SpringApplication in project x-pipe by ctripcorp.
the class RetryableRestOperationsTest method startUp.
@Before
public void startUp() {
port = randomPort(8081, 9090);
targetResponse = randomString();
System.setProperty("server.port", String.valueOf(port));
System.setProperty("target-response", targetResponse);
SpringApplication app = new SpringApplication(SimpleTestSpringServer.class);
app.setBannerMode(Mode.OFF);
ctx = app.run("");
ctx.start();
}
use of org.springframework.boot.SpringApplication in project x-pipe by ctripcorp.
the class TestMetaServer method doStart.
@Override
public void doStart() throws Exception {
System.setProperty(DefaultDcMetaCache.MEMORY_META_SERVER_DAO_KEY, configFile);
System.setProperty("TOTAL_SLOTS", String.valueOf(total_slots));
SpringApplication application = new SpringApplication(TestMetaServer.class);
application.setBannerMode(Mode.OFF);
application.setEnvironment(createEnvironment());
context = application.run(new String[] {});
TestZkClient client = context.getBean(TestZkClient.class);
DefaultZkConfig zkConfig = new DefaultZkConfig();
zkConfig.setZkSessionTimeoutMillis(zkSessionTimeoutMillis);
client.setZkConfig(zkConfig);
client.setZkAddress(zkConnectionStr);
UnitTestServerConfig config = context.getBean(UnitTestServerConfig.class);
config.setZkAddress(zkConnectionStr);
config.setMetaServerId(serverId);
config.setMetaServerPort(serverPort);
ArrangeTaskTrigger arrangeTaskTrigger = context.getBean(ArrangeTaskTrigger.class);
arrangeTaskTrigger.setWaitForRestartTimeMills(waitForRestartTimeMills);
manager = context.getBean(SpringComponentRegistry.class);
manager.initialize();
manager.start();
}
use of org.springframework.boot.SpringApplication in project x-pipe by ctripcorp.
the class ApplicationTest method testRun.
@Test
public void testRun() throws IOException {
System.setProperty(AbstractProfile.PROFILE_KEY, AbstractProfile.PROFILE_NAME_PRODUCTION);
System.setProperty("TOTAL_SLOTS", String.valueOf(16));
System.setProperty(DefaultDcMetaCache.MEMORY_META_SERVER_DAO_KEY, "metaserver--jq.xml");
startZk(2181);
new SpringApplication(MetaServerApplication.class).run();
waitForAnyKeyToExit();
}
Aggregations