pom.xml中配置生成startup.sh,shutdown.sh
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>manifest</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo file="target/startup.sh">
#!/bin/bash


java -cp "libs/*:zooServer.jar" com.yunix.MainServer &
echo $! > MainServer.pid
</echo>
<echo file="target/shutdown.sh">
kill `cat MainServer.pid`
</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>