进程 'command 'C:\Program Files\Java\jdk\bin\java.exe'' 以非零退出值 1 eclipse 结束

Dur*_*rga 5 gradle build.gradle

**Error :** Process 'command 'C:\Program Files\Java\jdk\bin\java.exe'' finished with non-zero exit value 1
Run Code Online (Sandbox Code Playgroud)

当我运行 build.gradle 文件的任务时出现此错误,如下所示,

 plugins {
    id 'application'
    id 'eclipse'
}

// remove the Javadoc verification
tasks.withType(Javadoc) {
    options.addStringOption('Xdoclint:none', '-quiet')
}

// Build version
version = '1.2.6-SNAPSHOT'

sourceCompatibility = '1.8'

artifactory {
    publish {
         repository.repoKey = 'ent-public-local-builds'
    }
}

eclipse.classpath {
    containers = containers.collect {
        it.replace 'org.eclipse.jdt.launching.JRE_CONTAINER',
            'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/DeveloperJavaJDK'
    }
}

//Core Spring version numbers
def springVersion = '5.1.9.RELEASE'
def springBatchVersion = '4.1.2.RELEASE'

//Junit version
def junitVersion = '5.5.1'

//updated to use Transitive Dependencies
dependencies {
    // include Spring JARs and dependencies
    implementation 'org.springframework:spring-oxm:' + springVersion
    implementation 'org.springframework:spring-webmvc:' + springVersion
}

reporting.baseDir = "my-reports"
testResultsDirName = "$buildDir/my-test-results"

application {
    mainClassName = 'com.automation.MyClass'
}
task runWithJavaExec(type: JavaExec) {
   // group = 'Execution'
   // description = "Run the main class with JavaExecTask"
    classpath = sourceSets.main.runtimeClasspath
    main = 'com.automation.MyClass'
}
runWithJavaExec.onlyIf { project.hasProperty('Execution')}
Run Code Online (Sandbox Code Playgroud)

我使用以下命令运行此任务,

gradle runWithJavaExec
Run Code Online (Sandbox Code Playgroud)

最后,我想知道如何通过 gradle 命令运行 java 类?除了创建任务之外还有其他可能吗?如果是,请相应地分享。请帮我解决这个问题。

小智 23

如果您使用的是intellij,只需使缓存无效并重新启动

  • 需要具体步骤来执行此操作 (7认同)
  • 这解决了我的问题。步骤非常基本...文件 - >使缓存无效.. - >使缓存无效并重新启动我能够通过此链接使缓存无效并重新启动https://www.jetbrains.com/help/idea/invalidate-caches.html (4认同)

小智 7

这种情况通常发生在您在代码中定义属性文件或某个文件时,但是当应用程序运行时尝试获取该文件但无法在项目中找到文件。您应该将文件移动到资源文件夹。