0

我有一个使用 Java 8 构建/编译的多模块 Maven 项目。

我最近刚刚安装了 OpenJDK 11,以便将项目升级到 Java 11。在实际更新任何组件等之前,我想将我的 Java 8 项目编译为 Java 8,但使用 Java 11 编译器。

我更新了我的父母pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <release>8</release>
    </configuration>
</plugin>

我能够毫无问题地编译所有源代码。

当我去运行我的测试时mvn test

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error creating lazy proxy.  Cause: java.lang.NullPointerException
        at org.apache.ibatis.javassist.util.proxy.SecurityActions.setAccessible(SecurityActions.java:103)
        at org.apache.ibatis.javassist.util.proxy.DefineClassHelper.toClass3(DefineClassHelper.java:151)
        at org.apache.ibatis.javassist.util.proxy.DefineClassHelper.toClass2(DefineClassHelper.java:134)
        at org.apache.ibatis.javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:95)
        at org.apache.ibatis.javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:131)
        at org.apache.ibatis.javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:530)
        at org.apache.ibatis.javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:515)
        at org.apache.ibatis.javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:451)
        at org.apache.ibatis.javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:422)
        at org.apache.ibatis.javassist.util.proxy.ProxyFactory.create(ProxyFactory.java:698)
        at org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory.crateProxy(JavassistProxyFactory.java:94)
        at org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory$EnhancedResultObjectProxyImpl.createProxy(JavassistProxyFactory.java:125)
        at org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory.createProxy(JavassistProxyFactory.java:61)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:600)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:396)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:355)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:330)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:303)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:196)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
        at org.apache.ibatis.executor.ReuseExecutor.doQuery(ReuseExecutor.java:60)
        at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326)
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
        at org.apache.ibatis.executor.loader.ResultLoader.selectList(ResultLoader.java:81)
        at org.apache.ibatis.executor.loader.ResultLoader.loadResult(ResultLoader.java:70)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getNestedQueryMappingValue(DefaultResultSetHandler.java:772)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(DefaultResultSetHandler.java:464)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:440)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:403)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:355)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:330)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:303)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:196)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
        at org.apache.ibatis.executor.ReuseExecutor.doQuery(ReuseExecutor.java:60)
        at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326)
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
        at jdk.internal.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
        at com.sun.proxy.$Proxy27.selectList(Unknown Source)
        at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)

我的理解是,通过使用<release>标签,编译器不仅会针对指定的版本进行字节码兼容性,而且还会使用正确的 JDK 包。这似乎在某种程度上完成了它的工作,因为编译工作正常,但测试的运行却没有。

4

0 回答 0