Search code examples
javaspringazurejava-19

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


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?


Solution

  • 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