切换到java 11后,com.sun.org.apache.xerces.internal.dom#DOMInputImpl()出现了问题。在下面的代码中:
@Override
public LSInput resolveResource(final String type,
final String namespaceURI, final String publicId, String systemId,
final String baseURI) {
final LSInput input = new DOMInputImpl();
if (systemId.equals(this.systemId)) {
try {
input.setByteStream(xsdFile.getInputStream());
} catch (IOException e) {
log.error("Error to get classpath resource for schema");
}
}
return input;
}在编译时,我得到了错误:
错误:(8,42) java:包com.sun.org.apache.xerces.internal.dom不可见
我试过添加maven-surefire-plugin -.但这对我没什么帮助
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<argLine>--illegal-access=permit</argLine>
<argLine>--add-exports java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED</argLine>
<argLine>-Dillegal-access=permit</argLine>
</configuration>
</plugin>发布于 2021-07-16 11:31:07
您应该使用原始的xerces实现。
这个问题在这里也得到了回答:https://github.com/adoptium/adoptium-support/issues/199#issuecomment-717008260
与JDK 9结合,介绍了Java平台模块系统。作为其中的一部分,对内部API的访问被关闭,而这些API本来不应该被使用。解决方案:升级依赖项,停止使用内部API。在Xerces的例子中,库可以从https://xerces.apache.org/.
获得。
https://stackoverflow.com/questions/68407913
复制相似问题