AOP

Deploy Spring Boot Application On Tomcat And Set SSL

Deploy Spring Boot Application On Tomcat And Set SSL

Posted by Kuo on June 9, 2019

1. Package project as War

There are just two items you need to change to your configuration

  • how to package project: <packaging>war</packaging>
  • export name package name <finalName>finalName</finalName> then
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <packaging>war</packaging>

    ...

    <build>
        <finalName>finalName</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Then package project as war

$ mvn package

Upload your war to production server with pscp

2. Install and config Tomcat

$ Wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.41/bin/apache-tomcat-8.5.41.zip
$ unzip apache-tomcat-8.5.41.zip

copy war file into tomcat/webapps/ the application will be unziped automatacally, open tomcat/conf/service.xml, change two configurations

  • Add a https connector ```xml
- Change host to host app
```xml
     <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">
        <Context path="" docBase="/var/tomcat/webapps/apps" debug="0" reloadable="true"/>