Home > Java > javaTutorial > How to deploy jar package in springboot

How to deploy jar package in springboot

王林
Release: 2023-05-11 13:13:06
forward
1664 people have browsed it

Since springboot commonly deploys war packages, when it is changed to cloud development mode with multiple ports, the deployment is not used to it

After all, the war package must be placed in the root directory of tomcat whether it is accessed by the project name or not

This directory is restricted to only one project, and the login port is limited to the tomcat interface

Therefore, jar package deployment has become an inevitable method

1. Add pom settings

Static files need to be accessed, so the files under the static file webapp need to be re-specified. The specific configuration is as follows

<resource>
 <directory>src/main/webapp</directory>
 <targetPath>META-INF/resources</targetPath>
 <includes>
 <include>**/*.*</include>
 </includes>
 <filtering>false</filtering>
</resource>
Copy after login

2. The packaging method is from war Change the package to a jar package

1. Comment the war package mode

<!--<packaging>war</packaging>-->
<packaging>jar</packaging>
Copy after login

2. Comment the war-plugin

<!--<build>
 <plugins>
 <plugin>
				<artifactId>maven-war-plugin</artifactId>
				<version>3.0.0</version>
		</plugin>
	</plugins>
</build>-->

<build>
<plugins>
 <plugin>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-maven-plugin</artifactId>
 <configuration>
 <mainClass>org.supwisdom.Application</mainClass> 
 </configuration>
 </plugin>
</plugins>
</build>
Copy after login

3. Comment out spring-boot-starter-tomcat related dependencies

4. Comment out SpringApplicationBuilder configure## in Application.java
#

// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(Application.class);
// }
 
 public static void main(String[] args) throws Exception {
 	System.setProperty("spring.devtools.restart.enabled", "false");
 SpringApplication.run(Application.class, args);
 }
Copy after login

Startup method:

cd The current service pom.xml is in the same directory


mvn clean package
java -jar target/***.jar
Copy after login
But the actual Certain problems occurred during use. For example, during development, modifications to the static file code did not always respond, and clearing the browser cache was of no use.

Therefore, the cache exists in the jar packaged by springboot. , so it is better to comment out the above content during development

The above is the detailed content of How to deploy jar package in springboot. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template