Spring boot project related configuration

 

 

FAQ1: Detailed tutorial on deploying to tomcat with war package (to solve the problem of missing web.xml error)

1. First modify the packaging method under pom.xml

<packaging>war</packaging>

 2. Add servlet-api dependency

<!--Add servlet-api dependency-->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>

 3. Remove the tomcat module embedded in springboot

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <!-- remove embedded tomcat plugin-->
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>

 4. Modify the compile settings

<build>
  <plugins>
    <plugin>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.6</version>
      <configuration>
        <!--Set to false if you want to build the WAR without a web.xml file. -->      
        <failOnMissingWebXml> false </failOnMissingWebXml>                        
      </configuration>
    </plugin>
  </plugins>
</build>

 

FAQ2: Solve the relative path problem of springboot front page

The springboot framework can run directly as a jar. In this way, the default contextPath is /. The front-end access path is "/test/page1", and it will automatically jump to the http://localhost:8080/test/page1 path, but when the project is deployed to tomcat in the form of a war package, it needs to be added when accessing The project name, such as project1, the contextPath at this time is /project1. In this case, the previous relative path writing "/test1/page1" can't be used at all, because it will automatically jump to http://localhost: 8080/test/page1 address, obviously, /project1 is missing here, the correct path is http://localhost:8080/project1/test/page1

 

1. Transfer all the project files extracted from the war package to the ROOT folder of tomcat, and empty or transfer the original files in the ROOT folder, so that root directory access can also be achieved.

 

Reference: http://blog.csdn.net/qq_35603331/article/details/76255125

 

FAQ3: Modify Tomcat's default port 8080

Modify the Tomcat/conf/Server.xml file and change port="8080" to something else. Such as port="8081", etc.:

<Connector port="8080" protocol="HTTP/1.1" 

               maxThreads="150" connectionTimeout="20000" 

               redirectPort="8443" />

 

Save the server.xml file, restart the Tomcat server, and Tomcat can use port 8081.

Note that sometimes two tomcats are used, so you need to modify the port number of one of them to make the two work at the same time.

After modifying the above, there are two more modifications:

(1)将 <Connector port="8009" enableLookups="false" redirectPort="8443" debug="0"

Change the 8009 of protocol="AJP/1.3" /> to another port.

(2) Continue to change the 8005 of <Server port="8005" shutdown="SHUTDOWN" debug="0"> to other ports.

After the above 3 modifications, it should be fine.

Reference: http://blog.csdn.net/alongwilliam/article/details/8199974

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326787606&siteId=291194637