Jhipster gradle build failde

时间:2017-01-20 15:07:38

标签: jhipster

从命令行运行jhipster时出现以下错误,我在Windows机器上使用jhipster最新版本(v3.12.2)。 gradle build似乎存在问题。

gradlew.bat bootRun
:cleanResources
:bootBuildInfo
:bower
:nodeSetup SKIPPED
:gulpConstantDev
[15:59:03] Using gulpfile C:\dev\test\gulpfile.js
[15:59:03] Starting 'ngconstant:dev'...
[15:59:03] Finished 'ngconstant:dev' after 23 ms
                                                                                                                                           :processResources
:compileJava
:classes
:findMainClass
:pathingJar
:bootRun
java.lang.NoClassDefFoundError: org/springframework/core/env/Environment
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.springframework.core.env.Environment
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" :bootRun FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1

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

BUILD FAILED

Total time: 15.498 secs

使用Maven工作。

此致

1 个答案:

答案 0 :(得分:2)

是的,此版本存在一个gradle问题,如果gradle缓存路径包含空格,则会产生此错误。我建议您将gradle缓存永久删除到没有空格的路径:Set Gradle Cache Directory?

如果您需要像我一样的临时快速修复,您可以使用脏方法修补此修复JHipster类路径。假设您的Windows用户名是“您的名字”。然后它将成为路径字符串的一部分,你将需要用“你的〜1”替换它(它是8个字符等效的Windows长名称目录,即目录名称的前6个字符小写,没有空格+“ 〜1" )。您可以在build.gradle第55行修补它,问题就消失了:

        attributes 'Class-Path': configurations.runtime.files.collect {
            it.toURL().toString().replaceFirst(/file:\/+/, '/').replace("Your Name", "yourna~1")
        }.join(' ')