使用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包装器的输出:
    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$
    

    最佳答案

    您可能正在遇到一个错误,该错误使您的符号链接(symbolic link)与报告的herehere悬卡在一起。建议的解决方案是重新安装ca-certificates-java软件包。像这样:

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

    07-24 20:37