In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to package a spring boot project into a war package through eclipse". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to package a spring boot project into a war package through eclipse".
1. Packing
Modify the form of packaging
Set up in pom.xml
Packaging > war
Except for embedded tomcat plug-in
Find the spring-boot-starter-web dependency node in pom.xml and add the following code to it
Org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat
Add servlet-api dependency
You can do either of the following two ways, either way
Javax.servlet javax.servlet-api 3.1.0 provided
I use the following way to change the version information to the corresponding tomcat version information
Org.apache.tomcat tomcat-servlet-api 8.5.20 provided
To define the name of the project package, add the following configuration
Project name org.springframework.boot spring-boot-maven-plugin
Modify the startup class, and override the initialization method
Our method needs a configuration similar to web.xml to start the spring context, adding a SpringBootStartApplication class at the same level of the Application class with the following code:
/ * modify the startup class, inherit SpringBootServletInitializer and override the configure method * / public class SpringBootStartApplication extends SpringBootServletInitializer {public static void main (String [] args) {SpringApplication.run (SpringBootStartApplication .class, args) } / * add this method * / @ Override protected SpringApplicationBuilder configure (SpringApplicationBuilder builder) {/ / Note here to point to the Application startup class return builder.sources (SpringBootStartApplication .cl ass) that was originally executed with the main method;}}
2. Package:
Right click on the project-> run as- > maven build:
Fill in the two places shown by the arrow; then click apply- to complete the project packaging.
3. Deployment
Put the war package in the target directory under the tomcat webapps directory, start tomcat, and you can automatically extract the deployment: (under the tomcat/bi directory, double-click startup.bat to start the tomcat, start successfully, and automatically decompress the deployment to run)
4. Finally
Finally, enter it in the browser
Http://localhost:8080/[ type project name] /
Note: the port number is based on the one specified in tomcat configuration, not in springboot. The project name must be added, that is, the name of the war package, before you can access your previous request path.
Thank you for your reading, the above is the content of "how to package spring boot projects into war packages through eclipse". After the study of this article, I believe you have a deeper understanding of how to package spring boot projects into war packages through eclipse. Specific use also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.