Java 8上的Spring Boot应用程序的gradle包装器失败,Gradle 3:无法找到cacerts

时间:2016-09-12 13:19:46

标签: gradle spring-boot gradlew

使用gradle wrapper命令创建gradlew文件时遇到问题。我的设置很简单:Ubuntu 14.04 + Java 8(openjdk版本“1.8.0_91”)+ Gradle 3.0

使用的教程:

这个问题的奇怪之处在于gradle wrapper失败的原因是因为cacerts文件或目录显然已丢失 - 但事实并非如此(请参阅下面的'检查cacerts文件/目录')。虽然 - 如果这是问题,请告诉我 - 这是一个链接,而不是实际的文件/目录。我不知道是否有任何其他问题,因为缺少cacerts错误似乎是在一连串的错误结束,但任何帮助调试这将是赞赏。

我的相关文件和输出如下所示。

干杯

AHL

的build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
    baseName = 'gs-spring-boot'
    version =  '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    // tag::jetty[]
    compile("org.springframework.boot:spring-boot-starter-web") {
        exclude module: "spring-boot-starter-tomcat"
    }
    compile("org.springframework.boot:spring-boot-starter-jetty")
    // end::jetty[]
    // tag::actuator[]
    compile("org.springframework.boot:spring-boot-starter-actuator")
    // end::actuator[]
    testCompile("junit:junit")
}

问题/错误:

org.apache.http.ssl.SSLInitializationException: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts (No such file or directory)

检查cacerts文件/目录:

vagrant@vagrant:/vagrant/BootTutorial$ ll /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts
lrwxrwxrwx 1 root root 27 Apr 22 13:29 /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts -> /etc/ssl/certs/java/cacerts
vagrant@vagrant:/vagrant/BootTutorial$

从运行的gradle包装器输出:

vagrant@vagrant:/vagrant/BootTutorial$ gradle wrapper --gradle-version 3.0 --info
Initialized native services in: /home/vagrant/.gradle/native
Connected to daemon DaemonInfo{pid=21004, address=[61084cbc-02a2-47e1-9f7b-07d285c509b7 port:43425, addresses:[/0:0:0:0:0:0:0:1%lo, /127.0.0.1]], idle=true, lastBusy=1473685805551, context=DefaultDaemonContext[uid=b5dcb202-0edb-4f81-bd5b-bd4b828045a5,javaHome=/usr/lib/jvm/java-8-openjdk-amd64,daemonRegistryDir=/home/vagrant/.gradle/daemon,pid=21004,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]}. Dispatching request Build{id=ac0e688f-bffe-4828-abe8-58f12354dcf6.1, currentDir=/vagrant/BootTutorial}.
Received result org.gradle.launcher.daemon.protocol.BuildStarted@6986852 from daemon DaemonInfo{pid=21004, address=[61084cbc-02a2-47e1-9f7b-07d285c509b7 port:43425, addresses:[/0:0:0:0:0:0:0:1%lo, /127.0.0.1]], idle=true, lastBusy=1473685805551, context=DefaultDaemonContext[uid=b5dcb202-0edb-4f81-bd5b-bd4b828045a5,javaHome=/usr/lib/jvm/java-8-openjdk-amd64,daemonRegistryDir=/home/vagrant/.gradle/daemon,pid=21004,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be starting).
The client will now receive all logging from the daemon (pid: 21004). The daemon log file: /home/vagrant/.gradle/daemon/3.0/daemon-21004.out.log
Starting 7th build in daemon [uptime: 39 mins 8.147 secs, performance: 91%]
Executing build with daemon context: DefaultDaemonContext[uid=b5dcb202-0edb-4f81-bd5b-bd4b828045a5,javaHome=/usr/lib/jvm/java-8-openjdk-amd64,daemonRegistryDir=/home/vagrant/.gradle/daemon,pid=21004,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
Starting Build
Settings evaluated using settings file '/master/settings.gradle'.
Projects loaded. Root project using build file '/vagrant/BootTutorial/build.gradle'.
Included projects: [root project 'BootTutorial']
Evaluating root project 'BootTutorial' using build file '/vagrant/BootTutorial/build.gradle'.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'BootTutorial'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE.
     Required by:
         :BootTutorial:unspecified
      > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE.
         > Could not get resource 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.4.0.RELEASE/spring-boot-gradle-plugin-1.4.0.RELEASE.pom'.
            > org.apache.http.ssl.SSLInitializationException: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts (No such file or directory)

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 1.391 secs
Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'BootTutorial'.] from daemon DaemonInfo{pid=21004, address=[61084cbc-02a2-47e1-9f7b-07d285c509b7 port:43425, addresses:[/0:0:0:0:0:0:0:1%lo, /127.0.0.1]], idle=true, lastBusy=1473685805551, context=DefaultDaemonContext[uid=b5dcb202-0edb-4f81-bd5b-bd4b828045a5,javaHome=/usr/lib/jvm/java-8-openjdk-amd64,daemonRegistryDir=/home/vagrant/.gradle/daemon,pid=21004,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).
vagrant@vagrant:/vagrant/BootTutorial$

1 个答案:

答案 0 :(得分:1)

你可能会遇到一个错误,这个错误会使你的符号链接留下报告herehere悬挂的证书。一个建议的解决方案是重新安装ca-certificates-java包。像这样:

$ sudo dpkg --purge --force-depends ca-certificates-java
$ sudo apt-get install ca-certificates-java