简体   繁体   English

当你有 jdk 1.8 代码时,你如何执行 maven 的 spring-boot:run?

[英]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.

相关问题 如何运行gulp任务和spring-boot:与maven一起运行? - How to run gulp task and spring-boot:run together with maven? Maven和spring-boot:如何在spring-boot:repackage上指定配置文件 - Maven and spring-boot: how to specify profile(s) on spring-boot:repackage spring-boot:run如何与Maven配合使用? - How does spring-boot:run work with maven? 您如何配置prometheus.yml文件以在Spring-Boot应用程序中收集Prometheus指标? - How do you configure prometheus.yml file to collect Prometheus metrics in a Spring-Boot application? 如何从终端执行 spring-boot:run 以进行远程调试 - How to execute spring-boot:run from terminal for Remote Debugging 如何防止Maven的spring-boot插件将静态资源复制到目标? - How do I prevent Maven's spring-boot plugin from copying static resources to target? Netflix Eureka Server 未使用 JDK 11 作为 Spring-Boot 应用程序启动。 但同样是在 JDK1.8 上运行 - Netflix Eureka Server Not starting as Spring-Boot Application with JDK 11 . But same is running with JDK1.8 如何在 vs 代码中调试 Java maven spring-boot 应用程序? - How to debug a Java maven spring-boot app in vs code? Spring-Maven 应用程序无法执行“mvn spring-boot:run” - Spring-Maven app can't execute "mvn spring-boot:run" 当 spring-boot 运行时,IntelliJ 进程以退出代码 0 完成 - IntelliJ Process finished with exit code 0 when spring-boot run
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM