本文整理匯總了Java中org.springframework.boot.SpringApplication.addListeners方法的典型用法代碼示例。如果您正苦於以下問題:Java SpringApplication.addListeners方法的具體用法?Java SpringApplication.addListeners怎麽用?Java SpringApplication.addListeners使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.boot.SpringApplication
的用法示例。
在下文中一共展示了SpringApplication.addListeners方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
final SpringApplication app = new SpringApplication(Application.class);
// save the pid into a file...
app.addListeners(new ApplicationPidFileWriter("smarti.pid"));
final ConfigurableApplicationContext context = app.run(args);
final ConfigurableEnvironment env = context.getEnvironment();
try {
//http://localhost:8080/admin/index.html
final URI uri = new URI(
(env.getProperty("server.ssl.enabled", Boolean.class, false) ? "https" : "http"),
null,
(env.getProperty("server.address", "localhost")),
(env.getProperty("server.port", Integer.class, 8080)),
(env.getProperty("server.context-path", "/")).replaceAll("//+", "/"),
null, null);
log.info("{} started: {}",
env.getProperty("server.display-name", context.getDisplayName()),
uri);
} catch (URISyntaxException e) {
log.warn("Could not build launch-url: {}", e.getMessage());
}
}
示例2: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
// SpringApplication.run(TulingchatApplication.class, args);
SpringApplication application = new SpringApplication(TulingchatApplication.class);
//注冊監聽器
application.addListeners(new PropertiesListener("application.properties"));
application.run(args);
}
示例3: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Application.class);
springApplication.addListeners(new ApplicationPidFileWriter());
ApplicationContext ctx = springApplication.run(args);
Assert.notNull(ctx, "May not be null!");
}
示例4: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication bootstrap = new SpringApplication(SpringBootRunner.class);
bootstrap.addListeners(new MyStartListner());
// 對Context進行最後的設置工作
bootstrap.addInitializers(new MyContextInitializer());
// 增加命令
ConfigurableApplicationContext context = bootstrap.run(args);
// 觸發一個事件
MyTellEvent event = new MyTellEvent(context, "測試的事件信息");
context.publishEvent(event);
}
示例5: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(ApplicationStart.class);
springApplication.addListeners(new ApplicationPidFileWriter("thrush.pid"), new ThrushApplicationListener());
springApplication.run(args);
}
示例6: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(ConsoleApplicationStart.class);
springApplication.addListeners(new ApplicationPidFileWriter("console.pid"));
springApplication.run(args);
}
示例7: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(TaskApplicationStart.class);
springApplication.addListeners(new ApplicationPidFileWriter("task.pid"));
springApplication.run(args);
}
示例8: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(RagnarApplication.class);
springApplication.addListeners(new ApplicationPidFileWriter());
springApplication.run(args);
}
示例9: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
//SpringApplication.run(ItweetBootApplication.class, args);
SpringApplication springApplication =new SpringApplication(ItweetBootApplication.class);
springApplication.addListeners(new ApplicationStartup());
springApplication.run(args);
}
示例10: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(ApplicationStart.class);
springApplication.addListeners(new ApplicationPidFileWriter("qiuqiu.pid"));
springApplication.run(args);
}
示例11: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// standalone server for development
mainApp = new SpringApplication(Application.class);
// ask for updates
ThreadManager.runLater(() -> {
askForUpdate();
});
logger.warn("Specified arguments: " + Arrays.asList(args));
if (Arrays.asList(args).contains(SpringConfiguration.DEV_PROFILE)) {
mainApp.setAdditionalProfiles(SpringConfiguration.DEV_PROFILE);
}
// listen application to update files
UpdateFilesListener updater = new UpdateFilesListener();
updater.addPeer(Paths.get("src/main/resources"), Paths.get("target/classes"));
// first file update
mainApp.addListeners(updater);
// open browser on launch if needed
mainApp.addListeners((event) -> {
if (event instanceof ApplicationReadyEvent) {
SpringConfiguration config = ((ApplicationReadyEvent) event).getApplicationContext().getBean(SpringConfiguration.class);
if (config == null) {
logger.error("Configuration not ready");
return;
}
if (config.isLaunchBrowserOnStart() == true) {
showMainPage();
}
}
});
// run server
try {
mainApp.run(args);
} catch (Exception e) {
logger.error("Error while launching application: ", e);
// if not headless, show a dialog
if (GraphicsEnvironment.isHeadless() == false) {
String message = "<html><p>Unable to launch application: ";
if (e.getMessage() != null && e.getMessage().length() > 50) {
message += e.getMessage().substring(0, 50) + " ...";
} else {
message += e.getMessage();
}
message += "</p>";
message += "<p>First of all, check if software is not already launched (you will see an icon in your task bar)</p>";
message += "<p>Then try restarting the program. If this error persists, try restarting your computer and restart the program.</p></html>";
try {
JOptionPane.showMessageDialog(null,
message,
"Error",
JOptionPane.ERROR_MESSAGE);
} catch (Exception e2) {
logger.error("Unable to show graphical error: ", e2);
}
}
}
}
示例12: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication springApplication =new SpringApplication(DataAppConsumerApplication.class);
springApplication.addListeners(new ApplicationStartup());
springApplication.run(args);
logger.info("============= SpringBoot Start Success =============");
}
示例13: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication springApplication =new SpringApplication(DataAppServiceApplication.class);
springApplication.addListeners(new ApplicationStartup());
springApplication.run(args);
logger.info("============= SpringBoot Start Success =============");
}
示例14: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication sa = new SpringApplication(RefreshContextApplication.class);
sa.addListeners(new MyApplicationListener());
sa.run(args);
}
示例15: main
import org.springframework.boot.SpringApplication; //導入方法依賴的package包/類
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(PersephoneApplication.class);
springApplication.addListeners(new ApplicationPidFileWriter());
springApplication.run(args);
}