关于SpringBoot打包war文件部署到Tomcat Veröffentlicht am 2018-01-16 | Words count in article 165 字 | Reading time 1 分钟 1234567891011121314添加 pom插件 <finalName>jorden</finalName> <plugins> <!-- maven打包的时候告诉maven不需要web.xml,否刚会报找不到web.xml错误 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> 1234567891011添加 pom依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <!--<scope>provided</scope> --> </dependency> 1234567891011121314151617更改启动类@EnableWebMvc@MapperScan(basePackages = "com.jorden.li.dao")@SpringBootApplication@EnableRabbitpublic class ApplicationStart extends SpringBootServletInitializer { //jar启动 @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(ApplicationStart.class); } public static void main(String[] args) { SpringApplication.run(ApplicationStart.class, args); }} 进入项目跟目录。运行:mvn clean package spring-boot:repackage 会出现war文件,直接放到tomcat里面就好。