我使用 gradle ssh 插件进行部署:
```
task deploy(dependsOn: bootJar) {
def jar = bootJar.archiveFileName.get()
def dir = config.getProperty('deploy.dir')
def path = "${dir}/${jar}"
def port = config.getProperty('deploy.port')
doLast {
ssh.run {
session(remotes.server) {
put from: "${buildDir}/libs/${jar}", into: "${path}.bak"
execute """
source /root/.bash_profile;
kill `ps aux | grep -i ${jar} | grep -v grep | awk '{print \$2}'`;
mv -f ${path}.bak ${path};
nohup java -jar -Dfile.encoding=UTF-8 ${path} --server.port=${port} > /dev/null 2>&1 &
"""
}
}
}
}
```