Spring boot is packaged and deployed to Tomcat of remote server

preface

Spring boot projects are generally run with embedded Tomcat or jetty servers. War packages are rarely deployed to external service containers. Even if they are placed in Linux, they usually start the application class directly. However, sometimes we need to deploy to external servers, which is a bit troublesome for spring boot

I won't say much now. Let's take a look at the detailed introduction.

Environmental statement:

jdk:1.8

Server: Alibaba cloud, Ubuntu 16.04

springBoot:1.5. 9.RELEASE

objective

Package spring boot into Tomcat of remote server.

pom. xml

be careful

1. Maven plug-ins cannot use the plug-ins that come with springboot. I use this plug-in to report the following errors

Modify the Maven plug-in to

Note that I don't have a web xml。 So add more

2、

Finalname needs to match application The context path in YML is consistent.

3. You need to change the dependency of Tomcat to compile time

4. Springboot entry class, inheriting springbootservletinitializer and overriding

Including mainapplication Class is the entry class of springboot.

pack

To the root directory of the project. If you are using idea, enter directly here:

mvn clean package -DskipTests

After packaging, the corresponding will be generated in the target folder of the project War file

upload

Just drop the war file under webapps in Tomcat.

Unresolved issues:

Originally, I wanted to make a jar package directly. Then start springboot directly. Wunai is printed into a jar package and has been reporting errors in the Maven plug-in part. You can only print it into a war package and upload it to Tomcat.

If someone has solved this problem, please let me know.

In this article, it is said that this is a bug

https://issues.apache.org/jira/browse/MSITE-724

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>