springboot使用外置tomcat启动

打开pom文件,把打包格式设置为war

<packaging>war</packaging>

SpringBoot默认有内置的tomcat运行模块,可以在Application(继承SpringBootServletInitializer)中直接main启动。

如下配置可在外置tomcat容器中运行
<dependency>  
       <groupId>org.springframework.boot</groupId>  
       <artifactId>spring-boot-starter-web</artifactId>  
       <!-- 如果在使用自带tomcat请注释下面,如果使用第三方tomcat不要注释下面 -->  
        <exclusions>    
               <exclusion>    
                   <groupId>org.springframework.boot</groupId>    
                   <artifactId>spring-boot-starter-tomcat</artifactId>    
               </exclusion>    
           </exclusions>   
   </dependency> 
自定义打包名
<plugin>  
            <groupId>org.apache.maven.plugins</groupId>  
            <artifactId>maven-war-plugin</artifactId>  
            <configuration>  
                <warName>springboot</warName>  
            </configuration>  
  </plugin> 


猜你喜欢

转载自blog.csdn.net/lin252552/article/details/80677098
今日推荐