In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how the process of SpringBoot deployment is carried out. The content of the article is of high quality. Therefore, Xiaobian shares it with you as a reference. I hope that after reading this article, you will have a certain understanding of relevant knowledge.
preface
For traditional ssm or ssh project deployment, it will generally be packaged into a war package, or a compiled folder, and then put into tomcat webapps directory, if it is a war package, it will automatically extract it. Spring Boot will embed a Tomcat by default, so even web projects can be packaged directly into jar packages and run directly in java -jar.
Web projects created with Spring Initialzr (optionally packaged as jars) will have only one spring-boot-starter-web dependency.
org.springframework.boot spring-boot-starter-web
If you follow up, you will see that this dependency includes the spring-boot-starter-tomcat dependency. If you use the internal tomcat deployment, you don't need to modify the code, just run the Main method under xxApplication.
If you create a web project for war, the default will be an extra ServletInitializer file, and maven will have an extra spring-boot-starter-tomcat dependency. War projects can be started either with the Main method or with an external tomcat.
It seems that there is no problem. If the previous project uses jar, and the final deployment needs to use external tomcat, only the following modifications need to be made:
// 1. Add a ServletInitializer.java// 2. Add war to Maven. (default is jar)// 3. Added spring-boot-starter-tomcat dependency. (Tested, it doesn't matter if you don't add it, but since Spring Initialzr comes with it when it's created, it's better to add it)
If you are using JSP, there may be some minor issues.
General blog will write, if you need to use JSP, you need to add a dependency tomcat-embed-jasper:
org.apache.tomcat.embed tomcat-embed-jasper provided
Special attention should be paid to:
Although spring-boot-starter-web embeds tomcat, embedded spring-boot-starter-tomcat contains only tomcat-embed-core, not tomcat-embed-jasper. So you need to add this dependency separately.
To use external tomcat deployment and use JSP, you need the following configuration:
org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat org.apache.tomcat.embed tomcat-embed-jasper provided
By default, it is generally deployed directly as jar package. If you need to deploy a war package, the easiest way is to add war to pom and add the ServletInitializer file (required). If there is a need for JSP, add tomcat-embed-jasper and other dependencies as needed. As mentioned above or on other blogs, the scope of tomcat or jasper that needs to be excluded from the web package must be provided. In fact, after testing, it is the same whether it is changed or not. (If there is no conflict, it doesn't matter; if there is an error, pay special attention to these two places.)
About SpringBoot deployment process is how to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
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.