Java 8,Gradle 3 上的 Spring Boot 应用程序的 gradle 包装器失败:找不到 cacerts
Posted
技术标签:
【中文标题】Java 8,Gradle 3 上的 Spring Boot 应用程序的 gradle 包装器失败:找不到 cacerts【英文标题】:gradle wrapper fails for Spring Boot application on Java 8, Gradle 3: can't find cacerts 【发布时间】:2017-01-19 22:48:29 【问题描述】:我在使用gradle wrapper
命令创建我的 gradlew 文件时遇到了问题。我的设置很简单:Ubuntu 14.04 + Java 8(openjdk 版本“1.8.0_91”)+ Gradle 3.0
使用的教程:
https://spring.io/guides/gs/spring-boot/#scratch https://docs.gradle.org/current/userguide/gradle_wrapper.html这个问题的奇怪之处在于 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 wrapper 的输出:
vagrant@vagrant:/vagrant/BootTutorial$ gradle wrapper --gradle-version 3.0 --info
Initialized native services in: /home/vagrant/.gradle/native
Connected to daemon DaemonInfopid=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 Buildid=ac0e688f-bffe-4828-abe8-58f12354dcf6.1, currentDir=/vagrant/BootTutorial.
Received result org.gradle.launcher.daemon.protocol.BuildStarted@6986852 from daemon DaemonInfopid=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 DaemonInfopid=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】:您可能遇到了一个错误,导致您的证书符号链接悬空,正如报告的 here 和 here 所报告的那样。一种建议的解决方案是重新安装ca-certificates-java
软件包。像这样:
$ sudo dpkg --purge --force-depends ca-certificates-java
$ sudo apt-get install ca-certificates-java
【讨论】:
谢谢托拜厄斯。我对这个错误做了一些阅读,明天会试试这个: $ sudo dpkg --purge --force-depends ca-certificates-java 然后是 $ sudo apt-get install ca-certificates-java以上是关于Java 8,Gradle 3 上的 Spring Boot 应用程序的 gradle 包装器失败:找不到 cacerts的主要内容,如果未能解决你的问题,请参考以下文章
spring-如何将spring源码成功导入Eclipse中
Spring 学习 171005 Building Java Projects with Gradle
Java学习(随笔)—Spring boot以及Gradle相关