Spring Boot Azure 项目使得 `java.util.Comparator java.util.TreeMap.comparator` 可访问。

huangapple go评论70阅读模式
英文:

Spring boot azure project gives java.util.Comparator java.util.TreeMap.comparator accessible

问题

我使用了 Spring Initializer 创建了一个 Spring Boot 项目,并按照这个教程来配置 Azure。这是一个空项目。mvn clean installmvn 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

huangapple
  • 本文由 发表于 2023年2月18日 21:53:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75493795.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定