JAVA 9 + spring-boot 2.0 + maven 3.5.3,遇到ERROR包com.sun.org.apache.xerces.internal.parsers不可见

时间:2018-03-21 03:21:32

标签: spring-boot maven-3 java-9 maven-compiler-plugin

我在java 9 + spring-boot 2.0 + maven 3.5.3中成功执行spring-boot:run命令。 我想将项目java 7迁移到java 9.我的项目有很多库依赖项,并且由java 6或7编译。我知道内部api是个问题。 所以我添加了一个用于测试的类并运行它。它失败了如下错误。

  

包com.sun.org.apache.xerces.internal.parsers不可见     (包com.sun.org.apache.xerces.internal.parsers在模块java.xml中声明,不导出它)

所以我在maven-compiler-plugin中添加了compilerArgs选项。(因为默认情况下com.sun.org.apache.xerces.internal.parsers包是不可访问的)但是仍然会出现错误。

if ele == "H":

Maven调试日志就是这个。

  

[DEBUG] -d ... -classpath ... -g -parameters -nowarn -target 9 -source 9 -encoding UTF-8 --add-exports java.xml / com.sun = ALL-UNNAMED < / p>

我的测试课就是这样。

<artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <executions>
                ...
                        <compilerArgs>
                            <compilerArg></compilerArg>
                            <arg>--add-exports</arg>
                            <arg>java.xml/com.sun=ALL-UNNAMED</arg>
                        </compilerArgs>
                ...
            </executions>

0 个答案:

没有答案