com.lone.Application Maven / Gradle / Ivy
The newest version!
package com.lone;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import lombok.extern.slf4j.Slf4j;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Slf4j
@EnableSwagger2
@SpringBootApplication
@ServletComponentScan
@ComponentScan({ "com.lone.*.**" })
@EnableAutoConfiguration(exclude = { JpaRepositoriesAutoConfiguration.class// 禁止springboot自动加载持久化bean
})
public class Application {
public static void main(String[] args) throws UnknownHostException {
// System.setProperty("spring.devtools.restart.enabled", "true");
// SpringApplication.run(Application.class, args);
ConfigurableApplicationContext application = SpringApplication.run(Application.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
log.info("\n----------------------------------------------------------\n\t" +
"Application Lone-Boot is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
"swagger-ui: \thttp://" + ip + ":" + port + path + "/swagger-ui.html\n\t" +
"Doc: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
// @Bean
// public CommandLineRunner init(final RepositoryService repositoryService,
// final RuntimeService runtimeService,
// final TaskService taskService) {
//
// return new CommandLineRunner() {
// @Override
// public void run(String... strings) throws Exception {
// System.out.println("Number of process definitions : "
// + repositoryService.createProcessDefinitionQuery().count());
// System.out.println("Number of tasks : " + taskService.createTaskQuery().count());
//// runtimeService.startProcessInstanceByKey("oneTaskProcess");
//// System.out.println("Number of tasks after process start: "
//// + taskService.createTaskQuery().count());
// }
// };
// }
}
// 项目web容器部署打war包:
//public class PrjApplication extends SpringBootServletInitializer {
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(PrjApplication.class);
// }
//
//
// public static void main(String[] args) {
// System.setProperty("spring.devtools.restart.enabled", "true");
// SpringApplication.run(PrjApplication.class, args);
// }
//}