In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to package and deploy SpringBoot applications into WAR files in java. I hope you will get something after reading this article. Let's discuss it together.
Package Maven-based Spring Boot applications into WAR files
To change packaging in Maven-based Spring Boot applications generated using Spring Initializr or Vaadin Start tools, make the following changes in the pom.xml file:
1. The modified elements are as follows:
XML:
War
two。 If you plan to deploy to a different server than Apache Tomcat, do the following:
A) add Servlet API dependencies to the project. Be sure to use a version that matches your project. For example, in the case of a Vaadin application:
XML:
Javax.servlet javax.servlet-api 3.1.0 provided
B) exclude dependencies from if you are using Spring MVC,spring-boot-starter-tomcat, or from the dependency if you are using Vaadin. For example: spring-boot-starter-web dependencyvaadin-spring-boot-starter
XML:
Com.vaadin vaadin-spring-boot-starter... Org.springframework.boot spring-boot-starter-tomcat
3. Optional: if you want to simplify the name of the WAR file and always build a file with the same name but no version number, add the following to this section:
XML:
${project.artifactId}
4. Build and package the application by running the mvn package command. If you are using Vaadin, enable the production profile (mvn package-P production). You can find the WAR file in the target/ directory within the Maven project.
Deploy the WAR file to Apache Tomcat
To deploy the application configured in the previous section to the local instance of Apache Tomcat:
Download Apache Tomcat from the project website. Be sure to download the correct version, depending on the Java and Servlet API versions your application uses. For example, for Vaadin applications, download Apache Tomcat version 9.
Extract the downloaded file.
Start the server by running the start.sh or start.bat script that can be found in the bin/ directory within the Apache Tomcat installation directory. You may have to add execution permissions to the script files in the bin/ directory. For example, in a Unix-like operating system, run. Chmod + x bin/*.sh
Copy the WAR file from the target/ directory within the Maven project to the webapps/ directory within the Apache Tomcat installation directory.
The application should be automatically deployed and available on http://localhost:8080/your-war-file-name. If you are deploying to the root of the context (http://localhost:8080/), use ROOT.war.
Deploy the WAR file to Eclipse Jetty
To deploy a previously configured application to a local instance of Eclipse Jetty:
Download Eclipse Jetty from the project website. Be sure to download the correct version, depending on the Java and Servlet API versions your application uses. For example, for a Vaadin application, download Eclipse Jetty 9.
Extract the downloaded file.
If you downloaded Eclipse Jetty 10, configure the server by running java-jar start.jar-add-module=server,http,deploy in the Eclipse Jetty installation directory.
Start the server by running start.sh start in the bin/ directory within the Eclipse Jetty installation directory. You may have to run to add execution permissions to the script files in the bin/ directory. Chmod + x bin/*.sh
Copy the WAR file from the target/ directory within the Maven project to the web apps / directory within the Eclipse Jetty installation directory.
The application should be automatically deployed and available here. If you are deploying to a contextual root, use root.war.
After reading this article, I believe you have some understanding of "how to package and deploy SpringBoot applications into WAR files in java". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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.