我使用gradle编写了一个springboot项目,我想部署它。使用gradle部署springboot项目:执行失败的任务':deploytest'
这里来的我的代码部分build.gradle
:
remotes {
localtest {
host = '192.168.0.116'
user = 'root'
password = '*****'
}
}
task deploytest(dependsOn: build) << {
ssh.run {
session(remotes.localtest) {
put from: 'build/libs/test-0.0.1-SNAPSHOT.jar', into: '/opt/test/'
execute "cd /opt/tieba"
execute 'nohup java -jar -Dspring.profiles.active=test test-0.0.1-SNAPSHOT.jar & echo $! > application.pid'
}
}
}
然后我跑gradle deploytest
,但它满足了一个问题:
FAILURE: Build failed with an exception.
* Where:
Build file 'E:\github\spring-projects\test\build.gradle' line: 97
* What went wrong:
Execution failed for task ':deploytest'.
> reject HostKey: 192.168.0.116
详细
org.gradle。 api.tasks.TaskExecutionException:任务':deploytest'的执行失败。
产生的原因:com.jcraft.jsch.JSchException:拒绝HostKey:192.168.0.116
gradle error details 01 gradle error details 02
您可以登录到该主机的终端? – AdamSkywalker
服务器的公钥是否已经在您的known_hosts文件中?这可能是你面临的问题:http://anahorny.blogspot.co.at/2013/05/solution-for-comjcraftjschjschexception.html? –
@DavidTanzer感谢您的回答,它帮助了很多! –