IDEA project is packaged springboot war and posted to tomcat server

Recently, a springboot items to publish to run under a separate tomcat, which encountered many pits in this recording:

1.springboot project packaging configurations:

First class in the new package startup class directory

 Note: Start class inherits from SpringBootServletInitializer before deployment to normal conventional tomcat, it can play the role of main web.xml of (mainly web.xml configure various servlet, filter, listener, etc., such as the common Log4jConfigListener, OpenSessionInViewFilter, CharacterEncodingFilter, DispatcherServlet etc., this information is part of a container is loaded at startup)

2.pom file changes:

2.1 need to add these dependencies:

Which is consistent jdk and tomcat server version tomcat.version to set in! (Linux command: whereis java)

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <!-- 移除嵌入式tomcat插件 -->
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-juli</artifactId>
    <version>${tomcat.version}</version>
</dependency>

<build><plugins><plugins>中新增:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <finalName>${project.name}</finalName><!-- 打包后的war名称-->
    </configuration>
</plugin>

2.2 which need to be amended pom Tags:

<packaging>war</packaging>  打jar包需要改为jar

2.3IDEA execution:

 So after the war package

Publish to tomcat container under it.

Note where the tomcat server set up several points:

1. Modify the port number (three modified), prevent multiple tomcat conflict

2.tomcat specify jar need to modify setclasspath.sh add two statements:

the JAVA_HOME = Export / usr / Java / jdk1.8.0_65
Export the JRE_HOME = / usr / Java / jdk1.8.0_65 / JRE / (behind / not leak)

3. Modify the tomcat memory

 

 

 

发布了23 篇原创文章 · 获赞 4 · 访问量 1万+

Guess you like

Origin blog.csdn.net/qq1076472549/article/details/81318729