pom. 中

war

<groupId>org.spring work.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.1.RELEASE</version><relativePath/> <!-- lookup parent from repository -->


<plugins>    <plugin>        <groupId>org.apache.maven.plugins</groupId>        <artifactId>maven-surefire-plugin</artifactId>        <version>2.4.2</version>        <configuration>            <skipTests>true</skipTests>        </configuration>    </plugin></plugins>


添加依赖,打包时检查这两个依赖是否存在,不存在的话添加一下

<groupId>org.spring work.boot</groupId><artifactId>spring-boot-starter-web</artifactId>


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


启动类

@EnableTransactionManagement
@ServletComponentScan
@SpringBootApplication
public class SyscloudApplication extends SpringBootServletInitializer {

@Overrideprotected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {    return builder.sources(SyscloudApplication.class);}public static void main(String[] args) {    SpringApplication.run(SyscloudApplication.class, args);}

}
然后开始打包,修改后由于没有去掉自带的tomcat,所以项目可以正常通过springboot启动

要去掉tomcat时,将pom. 文件中的web依赖改为:

<groupId>org.spring work.boot</groupId><artifactId>spring-boot-starter-web</artifactId><!-- 移除嵌入式tomcat插件 --><exclusions>    <exclusion>        <groupId>org.spring work.boot</groupId>        <artifactId>spring-boot-starter-tomcat</artifactId>    </exclusion></exclusions>

收藏 打印