我在IntelliJ 2016.1中有一个非常烦人且无法解释的行为:
如果在构建文件中使用 Gradle 复制任务,IntelliJ 会在此文件中的任何编辑中添加此导入:
com.sun.org.apache.xalan.internal.xsltc.compiler.Copy
这当然不是必需的,因为此任务是内置的 Gradle。执行时,这会导致此错误:
无法创建类型为"复制"的任务,因为它没有实现任务 接口。
复制任务只是一个简单的任务,如下所示:
task copyNodeModules(type: Copy) {
group="_webapp"
from('./src/main/ts/node_modules') {
include '**/*'
exclude '**/lite-server'
exclude '**/json-server'
exclude '**/.bin'
}
into project.buildDir.path + '/resources/someFolder'
}
转到 Settings -> Auto Import -> Exclude from auto import and completion
和添加 'com.sun.org.apache.xalan.internal.xsltc.compiler'
为我解决了这个问题。
检查您的build.gradle,看看它是否包含在第一行,只需删除此行即可解决问题。
import com.sun.org.apache.xalan.internal.xsltc.compiler.Copy