[英]How do you execute maven's spring-boot:run when you have jdk 1.8 code?
I am effectively asking this question, but for the spring-boot:run
goal: how to pass --add-opens JDK module configuration to maven test我实际上是在问这个问题,但是对于
spring-boot:run
目标: 如何将 --add-opens JDK 模块配置传递给 maven 测试
For context, I'm trying to execute spring-boot 1.5.1.RELEASE code that was written for jdk1.8 in jdk16.对于上下文,我正在尝试执行为 jdk16 中的 jdk1.8 编写的 spring-boot 1.5.1.RELEASE 代码。 JDK 9 introduced the concept of modules, and this was a backwards incompatible change, though from my research, it looks like there are workarounds.
JDK 9 引入了模块的概念,这是一个向后不兼容的变化,尽管根据我的研究,看起来有一些变通方法。 When I run the code, I get this error:
当我运行代码时,我收到此错误:
Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module
Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base不会“打开 java.lang”到未命名的模块
Rather than add modules to this old project, I want to get past this with minimal modification to the existing project.我不想在这个旧项目中添加模块,而是希望通过对现有项目的最小修改来解决这个问题。 What do I have to do to run my application without adding modules?
在不添加模块的情况下运行我的应用程序需要做什么? one workaround I know would work is to download JDK 8 and run the code with that, but that doesn't seem like a good solution.
我知道可行的一种解决方法是下载 JDK 8 并使用它运行代码,但这似乎不是一个好的解决方案。
I think I found an answer, but I'd like to know if there's a better way:我想我找到了答案,但我想知道是否有更好的方法:
<build>
<finalName>project</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>--add-opens java.base/java.lang=ALL-UNNAMED</jvmArguments>
</configuration>
</plugin>
</plugins>
</build>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.