我正在为我的项目添加一些代码并且它工作正常,直到我再次运行它并给我这个错误消息:
4:46:46 PM: Executing external task 'run'...
Configuration on demand is an incubating feature.
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\me\Desktop\myProject\core\src\com\thiIsme\project\World\WorldController.java:10: error: package com.sun.xml.internal.bind.v2.runtime.reflect.opt does not exist
import com.sun.xml.internal.bind.v2.runtime.reflect.opt.Const;
^
1 error
1 warning
:core:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:compileJava'.
> Compilation failed; see the compiler error output for details.
* 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: 0.74 secs
Compilation failed; see the compiler error output for details.
4:46:47 PM: External task execution finished 'run'.
我很确定我收到错误的原因不是因为我新添加的代码,因为我对此进行了全面评论。
答案 0 :(得分:3)
错误:包com.sun.xml.internal.bind.v2.runtime.reflect.opt 不存在
从您的错误中,以下jar丢失了。所以
将此jar添加到dependencies
。希望它能解决你的问题。
// https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl
compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.2.11'
在您的项目中,您将获得build.gradle
个文件。打开它,会有一部分名为依赖项。您必须在依赖项中添加该行。
如果以前的情况如下:
dependencies {
compile group: 'log4j', name: 'log4j', version: '1.2.17'
}
添加此jar文件后,它将如下所示
dependencies {
compile group: 'log4j', name: 'log4j', version: '1.2.17'
compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.2.11' // This portion is added
}
要了解有关gradle的更多信息,您可以阅读以下教程: