I want to use RestTemplate/TestRestTemplate by including the artifact in a SpringBoot application
org.springframewo
You can just close the app according to https://spring.io/guides/gs/async-method/. Although this still stars Tomcat, but will stop the app at the end without keeping the tread running.
SpringApplication.run(MyApp.class, args).close();
Since Spring Boot 2.0.0 this property is deprecated and following is the new way:
spring.main.web-application-type=none
This change is because Spring Boot the support for reactive server.
Spring Boot is not going to start a web container if it's not present. spring-web
does not provide any embedded container. You may want to analyse the dependencies of your project (try mvn dependency:tree
).
If you want to make sure a web server is not started in your spring boot application, you can set the following configuration key
spring.main.web-application-type=none
Or you can use the SpringApplicationBuilder
new SpringApplicationBuilder(YourApp.class)
.web(WebApplicationType.NONE).run(args);