最近在學習jenkins 自動部署 發現自己寫的小demo ?在Jenkins 打包完部署到tomcat時 無法啟動后來經過查詢是內置的tomcat與服務器沖突 需要去掉內置的服務器
在啟動類繼承SpringBootServletInitializer 并重寫????configure方法
public class ProjectApplicationextends SpringBootServletInitializer {
@Override
? ? protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(ProjectApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(ProjectApplication.class, args);
}
}
然后在pom里面做下修改
<!--采用外部的tomcat 去掉內部tomcat-->
? ? ? ? <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>
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>org.apache.tomcat.embed</groupId>
? ? ? ? ? ? <artifactId>tomcat-embed-jasper</artifactId>
? ? ? ? ? ? <scope>provided</scope>
? ? ? ? </dependency>
2018年12月23日20:45:21
修正 在spring boot
?<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/>
</parent>
版本后不需要單獨設置修改pom文件 只需要采用默認就可以,不用單獨剔除tomcat
然后打包后直接扔到tomcat 自動會熱部署。