zoukankan      html  css  js  c++  java
  • IntelliJ IDEA Sringboot 项目部署到外部Tomcat服务器

    <packaging>war</packaging>
    

      添加依赖

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

      

          排除自带tomcat,不排除也没有影响,只是多了个jar包

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

      

    注释spring-boot-maven-plugin,使用maven-war-plugin

    <!-- 
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <mainClass>bing.AuthorityApplication</mainClass>
            <layout>ZIP</layout>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>repackage</goal>
                </goals>
            </execution>
        </executions>
    </plugin> -->
    
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
    </plugin>
    

      修改启动类

    //@SpringBootApplication
    //public class SpringlearnApplication {
    //
    //	public static void main(String[] args) {
    //		SpringApplication.run(SpringlearnApplication.class, args);
    //	}
    //}
    
    @SpringBootApplication
    public class SpringlearnApplication extends SpringBootServletInitializer {
    
    	@Override
    	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    		return application.sources(SpringlearnApplication.class);
    	}
    
    	public static void main(String[] args )
    	{
    		SpringApplication.run(SpringlearnApplication.class, args);
    	}
    }
    

     打包生成war

    从根目录启动,其中xxx为war的名称

    <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
        
        
        <Context path="" docBase="xxx" debug="0" reloadable="true"/>
        
        ...
    </Host>
    

      

  • 相关阅读:
    网络流与线性规划24题 之 餐巾计划问题
    待刷题目分类(一)
    bzoj1787 [Ahoi2008]Meet 紧急集合
    Hoj2634 How to earn more?
    poj3281 Dining
    浅谈数论(三)水仙花数
    poj1637 Sightseeing tour
    动态规划的思考(1)
    网络流-最大流问题 ISAP 算法解释(转自Renfei Song's Blog)
    poj1273 Drainage Ditches
  • 原文地址:https://www.cnblogs.com/nodegis/p/9811989.html
Copyright © 2011-2022 走看看