IntelliJ对Spring项目打jar包
成功方法一:
Run --> Edit Configurations --> Maven --> "+" --> Parameters --> Command line 填入clean package,上边Name中自己取一个名字(General中可以设置下Maven home directory、User settings file等) --> OK
在idea中启动刚刚配置的maven项目
启动成功后,可在项目target目录下看到带有版本号的项目jar文件。
成功方法二:
首先确保在pom.xml中配置了以下插件
<plugin> <!--打包成可执行jar--> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>
在idea右上角选择,Maven Projects --> 选择你的项目 --> Lifecycle --> install -->右键即可运行maven的install命令,改方法也可以在target下生成一个可执行jar。
该jar文件即dos窗口通过“java -jar gps-0.0.1-SNAPSHOT.jar”进行正常启动。