1.打包可执行jar工程文件:
工程右键->run as->maven build:
maven package
2.问题:[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Window->preferences->Java->Installed JREs->Add->Standard VM->next->Directory->JDK root路径->Finish->[Installed JREs勾选添加的JDK]
Window->preferences->Java->Installed JREs->Execution Environments->JavaSE-1.8->[勾选JDK]
3.打包jar的pom配置:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
4.执行jar包:
#开放端口
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
#执行jar包
java -jar package.jar