1. 程式人生 > >springboot專案打包部署到Tomcat

springboot專案打包部署到Tomcat

首先伺服器配置好tomcat以及環境變數

修改專案pom.xml檔案,加入兩個地方

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
</dependency>

<build>
        <finalName>XXXX</finalName>    //要加入finaName
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
</build>

 

 

啟動類要實現springbootservletInitializer類並實現configure方法

 

右擊專案選擇run as然後選擇maven build如下操作然後執行會在target目錄下生成war包

 

然後將war包複製到tomcat的webapp目錄下,啟動tomcat就可以解壓專案然後訪問了

 

tomcat相關操作命令

service.bat install

service.bat remove Tomcat8

net stop Tomcat8

net start Tomcat8