In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to close the tomcat container by springboot". In the daily operation, I believe many people have doubts about how to close the tomcat container by springboot. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to turn off the tomcat container by springboot". Next, please follow the editor to study!
Springboot, turn off the tomcat container.
Sometimes what you need to provide is not HTTP services, but RPC services, but you want to use the convenient support provided by springboot.
At this point, you need to shut down the RPC service and then add your own daemon thread in the main function.
Public static void main (String [] args) {SpringApplication app = new SpringApplication (Application.class); app.setWebApplicationType (WebApplicationType.NONE); app.run (args);} springboot uses third-party tomcat1. Change to pom
Because the code uses servlet's api, if you don't add it, you will report an error. Remove tomcat from web module
Org.springframework.boot spring-boot-starter-web spring-boot-starter-tomcat org.springframework.boot Javax.servlet javax.servlet-api provided
Plug-in comments the original springboot-maven plug-in, changed to war
You can change your name in warName, and this is the name of the package you will type.
Org.apache.maven.plugins maven-war-plugin springboot
Change the way of packing
War2. Add a startup class
Inherit SpringBootServletInitializer override configure method
@ SpringBootApplication@Configuration @ ComponentScan (basePackages= "com.jubao.dling") / / the default scan is the path under the current package @ EnableAutoConfiguration public class DlingApplication extends SpringBootServletInitializer {public static void main (String [] args) {SpringApplication.run (DlingApplication.class, args);} @ Override protected SpringApplicationBuilder configure (SpringApplicationBuilder application) {return application.sources (DlingApplication.class);}}
It is not necessary to delete the original startup class, because usually when developing, you must still use the built-in tomcat, and the tags that remove tomcat will be commented out during development.
3. Pack the war bag
Release tomcat to run
At this point, the study on "how to close the tomcat container by springboot" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.