英文:
Spring boot azure project gives java.util.Comparator java.util.TreeMap.comparator accessible
问题
我使用了 Spring Initializer 创建了一个 Spring Boot 项目,并按照这个教程来配置 Azure。这是一个空项目。mvn clean install
和 mvn clean package
运行正常。Spring Boot 应用程序也能正常启动。
pom 文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.dasdsad</groupId>
<artifactId>myProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myProject</name>
<description>Spring Boot 的演示项目</description>
<properties>
<java.version>19</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
当我执行 ./mvnw com.microsoft.azure:azure-spring-cloud-maven-plugin:1.3.0:config
时,出现了以下错误:
无法使私有最终 java.util.Comparator java.util.TreeMap.comparator 可访问:模块 java.base 不会将 java.util 打开到未命名模块 @67b61834
有人对这种行为有经验吗?
英文:
I created a spring boot project with spring initializer and I'm following this tutorial here to setup azure. It's an empty project. mvn clean install, mvn clean package runs fine. The spring boot app also starts properly.
https://spring.io/guides/gs/spring-boot-for-azure/
The pom looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.dasdsad</groupId>
<artifactId>myProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myProject</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>19</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When I do ./mvnw com.microsoft.azure:azure-spring-cloud-maven-plugin:1.3.0:config
I get this error:
Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @67b61834
Does anyone have experience with this behavior?
答案1
得分: 0
以下是解决方法:
导出 MAVEN_OPTS=" --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED"
这是 Azure Maven 插件的问题:https://github.com/microsoft/azure-maven-plugins/issues/2222
英文:
Here is the workaround:
export MAVEN_OPTS="--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED"
It is an issue in azure maven plugin: https://github.com/microsoft/azure-maven-plugins/issues/2222
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论