Springboot Packaging releases Tomcat encounters bugs and workarounds

Source: Internet
Author: User

1 、--in the packaging release Springboot, first in the Pom.xml springboot embedded Tomcat removed, so that when packaging will not hit the Tomcat jar package

As shown below:

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!--exclude built-in containers and exclude built-in containers from exporting to a war package allows external containers to run spring-boot items--
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>

</dependency>

If you also need inline tomcat, set the Tomcat scope scope to privided

As shown below:

<!--load built-in tomcat--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

<scope>privided</scope>

</dependency>

2 、--Pack The Springboot into a war directly after deploying to Tomcat's WebApps, the following problems are encountered

Want to access the project directly through the IP address, but found that the project executed two times in Tomcat boot, the first execution does not error, the second execution error

Workaround: Do not put the project under Tomcat's WebApps, put it in a different directory, and then configure the Server.xml file in the Config folder

For example, my configuration is placed in the D:\apache-tomcat-8.5.32\myproduct directory audio-0.0.1-snapshot is the project name

Unpackwars= "true" autodeploy= "true" >

<context path= "/" docbase= "D:\apache-tomcat-8.5.32\myproduct\audio-0.0.1-SNAPSHOT" debug= "0" Reloadable= "false" crosscontext= "false" >
</Context>
</Host>

This solves the problem, and starting Tomcat again will only be accessed once.

Springboot Packaging releases Tomcat encounters bugs and workarounds

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.