Idea打包springboot项目war包,测试通过
pom.xml文件
<!--包名以及版本号,这个是打包时候使用,版本可写可不写,建议写有利于维护系统-->
<artifactId>tsgdemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!--打包形式-->
<packaging>war</packaging><!--该依赖的作用是:在项目打包时,剔除springboot内置tomcat。-->
<!--如果没有该步骤,打成的war包内,会有关于内置tomcat的多余的jar包,但是并不影响项目最终的部署与运行。-->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><scope>provided</scope>
</dependency><!--加入SpringBoot打包插件(pom.xml)-->
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins>
</build>
springboot项目启动文件:
@SpringBootApplication
@MapperScan("com.sise.tsgdemo.mapper") //扫描的mapper
public class TsgdemoApplication {public static void main(String[] args) {SpringApplication.run(TsgdemoApplication.class, args);System.out.println("=======项目启动成功,欢迎使用=======");}//打包@Overrideprotected SpringApplicationBuilder configure(SpringApplicationBuilder application) {return application.sources(TsgdemoApplication.class);}
}
等maven加载完之后,准备打包:点击右侧的maven
先清理一下:clean,之后再package打包就行了