springboot关掉tomcat容器

294 阅读1分钟

有的时候需要对外提供的并不是HTTP服务,而是RPC服务,但是又想使用springboot提供的便利支持。这个时候需要关掉RPC服务,然后在main函数中自己添加守护线程

public static void main(String[] args) {
		SpringApplication app = new SpringApplication(Application.class);
		app.setWebApplicationType(WebApplicationType.NONE);
		app.run(args);
	}