如何解决在模块java.base中声明了包sun.net.www.protocol.https,该模块未导出
我正在尝试使用gradle6.6构建Java项目并在Eclipse 03-2020中打开jre 11.0.2。 在构建使用jrt-fs.jar中的类的项目时,我遇到编译问题。例如在开放的jre 11中的“ sun.net.www.protocol.http.Handler”。
public class Manager extends sun.net.www.protocol.https.Handler{
(package sun.net.www.protocol.https is declared in module java.base,which
does not export it)
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
以下是我的build.gradle:
apply plugin: 'java'
apply plugin: 'application'
allprojects {
apply plugin: 'java'
sourceCompatibility = '11.0.2'
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'lib',include: '*.jar')
compile group: 'org.hamcrest',name: 'hamcrest-all',version: '1.3'
compile group: 'junit',name: 'junit',version: '4.10'
compile group: 'jmock',name: 'jmock',version: '1.0.1'
compile group: 'com.google.code.findbugs',name: 'findbugs',version: '1.3.9'
compile group: 'cglib',name: 'cglib',version: '2.1'
testCompile group: 'junit',version: '4.10'
}
此外,如何避免通过gradle构建测试类?
解决方法
如@ dave_thompson_085所建议,问题是由于sun.net。*软件包上的模块化限制(从JDK-1.9起)所致,因为它们是JDK内部的。以上软件包可在JDK -1.8中访问。我们需要修复代码
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。