【发布时间】:2021-11-18 10:03:52
【问题描述】:
我正在尝试使用 jdk17 运行 java 8 批处理,该项目是使用 jre1.8.0_192 构建的,我在 VM 中放置了以下选项:
--add-modules=ALL-SYSTEM --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.math=ALL-UNNAMED --add- opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED - Djava.locale.providers=JRE,SPI
我在运行时收到以下错误:
java.lang.NullPointerException:无法调用“Object.getClass()” 因为“obj”在 java.lang.reflect.Method.invoke(Method.java:561) ~[?:?] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.25.RELEASE.jar:4.3.25.RELEASE] 在 org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.25.RELEASE.jar:4.3.25.RELEASE] 在 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.25.RELEASE.jar:4.3.25.RELEASE] 在 org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127) ~[spring-batch-core-3.0.10.RELEASE.jar:3.0.10.RELEASE] 在 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.25.RELEASE.jar:4.3.25.RELEASE] 在 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.25.RELEASE.jar:4.3.25.RELEASE]
有什么想法吗?谢谢
【问题讨论】:
-
如何将所有代码放在类路径中(不使用模块)? AFAIK 新的 Java 版本在以这种方式使用时是相当向后兼容的。
-
Spring 4.x 兼容 Java8 而不是更高版本,您至少需要 Spring 5.3 才能安全运行 JDK17。
-
你将如何继续在类路径中添加所有代码?
标签: java spring openjdk-17