1、pom.xml文件中增加以下配置
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><executions><execution><goals><goal>repackage</goal></goals></execution></executions><configuration><mainClass>com.konsy.TestProjectApplication</mainClass></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-release-plugin</artifactId><version>2.5.3</version></plugin></plugins></build>
2、点击maven插件中的package
3、到target目录下找到jar包
执行 java -jar xxxx.jar即可执行
4.如果是打第三方库
需要增加
<dependency><groupId>xxx.xxx.xxx</groupId> <!--自定义--><artifactId>xxx</artifactId> <!--自定义--><version>1.0</version> <!--自定义--><scope>system</scope> <!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它--><systemPath>${basedir}/libs/xxx.jar</systemPath> <!--项目根目录下的lib文件夹下--></dependency>
同时
<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><includeSystemScope>true</includeSystemScope></configuration></plugin>