通过 maven 把项目打成 jar
<build>
<finalName>test</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>io.Test</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
启动脚本
java -Xmx4000m -Xms4000m -Xmn1024m -XX:MetaspaceSize=128M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:HeapDumpPath=/Users/Downloads/ -verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCCause -Xloggc:/Users/Downloads/gc_app.log -jar $BASE/test.jar