类路径问题:Gradle 不工作
Classpath issue: Gradle not working
Netbeans 8.02 上的 Uinsg Gradle:
获取有关未自动添加到类路径的其他库的 Java 编译错误。
所以
import org.apache.poi.hssf.usermodel.HSSFCell;
产生错误
package org.apache.poi.hssf.usermodel does not exist
如何解决这个错误?
编辑:Gradle 构建文件:
apply plugin: 'java'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
repositories {
mavenCentral()
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
// TODO: Add dependencies here ...
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
testCompile group: 'junit', name: 'junit', version: '4.10'
}
您需要在 'compile' 要求中添加库依赖项。阅读有关依赖项的更多信息 here。依赖项可以在 public Maven 存储库中找到,或者如果您有自定义存储库,则可以添加自己的依赖项。
Netbeans 8.02 上的 Uinsg Gradle:
获取有关未自动添加到类路径的其他库的 Java 编译错误。
所以
import org.apache.poi.hssf.usermodel.HSSFCell;
产生错误
package org.apache.poi.hssf.usermodel does not exist
如何解决这个错误?
编辑:Gradle 构建文件:
apply plugin: 'java'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
repositories {
mavenCentral()
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
// TODO: Add dependencies here ...
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
testCompile group: 'junit', name: 'junit', version: '4.10'
}
您需要在 'compile' 要求中添加库依赖项。阅读有关依赖项的更多信息 here。依赖项可以在 public Maven 存储库中找到,或者如果您有自定义存储库,则可以添加自己的依赖项。