【问题标题】:Unable to make field private in spring boot Error无法在 Spring Boot 错误中将字段设为私有
【发布时间】:2021-06-19 10:22:05
【问题描述】:

我正在尝试克隆这个项目Repos 它给了我这个错误 java: java.lang.ExceptionInInitializerError 无法使字段私有 com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors com.sun.tools.javac.processing.JavacProcessingEnvironment.discoveredProcs 可访问:模块 jdk.compiler 没有“打开 com.sun.tools.javac.processing " 到未命名的模块 @27119bf

我正在关注这个Course 这是我的 POM.XML

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.github.sfg-beer-works</groupId>
        <artifactId>sfg-beer-works-bom</artifactId>
        <version>1.0.4</version>
    </parent>

<!--    <groupId>sfg.brewery</groupId>-->
    <artifactId>brewery-monolith</artifactId>
    <version>1.0-SNAPSHOT</version>

    <description>SFG Brewery Monolith UI</description>
    <name>SFG Brewery Monolith UI</name>

    <licenses>
        <license>
            <name>GNU General Public License v3.0</name>
            <url>https://www.gnu.org/licenses/gpl.txt</url>
        </license>
    </licenses>

    <organization>
        <name>Spring Framework Guru</name>
    </organization>

    <developers>
        <developer>
            <name>John Thompson</name>
            <organization>Spring Framework Guru</organization>
        </developer>
    </developers>
    
    <properties>
        <!-- Web dependencies -->
        <webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
        <webjars-jquery-ui.version>1.12.1</webjars-jquery-ui.version>
        <webjars-jquery.version>3.3.0</webjars-jquery.version>
        <wro4j.version>1.8.0</wro4j.version>
        <!--set this to your docker acct name-->
        <docker.image.prefix>sfgbeerworks</docker.image.prefix>
        <!--Set to name of project-->
        <docker.image.name>${artifactId}</docker.image.name>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</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-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
        </dependency>
        <!-- webjars -->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>${webjars-jquery.version}</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery-ui</artifactId>
            <version>${webjars-jquery-ui.version}</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>${webjars-bootstrap.version}</version>
        </dependency>
        <!-- end of webjars -->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>ro.isdc.wro4j</groupId>
                <artifactId>wro4j-maven-plugin</artifactId>
                <version>${wro4j.version}</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
                    </wroManagerFactory>
                    <cssDestinationFolder>${project.build.directory}/classes/static/resources/css</cssDestinationFolder>
                    <wroFile>${basedir}/src/main/wro/wro.xml</wroFile>
                    <extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile>
                    <contextFolder>${basedir}/src/main/less</contextFolder>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.webjars</groupId>
                        <artifactId>bootstrap</artifactId>
                        <version>${webjars-bootstrap.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.mockito</groupId>
                        <artifactId>mockito-core</artifactId>
                        <version>2.23.0</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${org.projectlombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                    <!--<dockerHost>http://127.0.0.1:2375</dockerHost>-->
                    <dockerHost>unix:///var/run/docker.sock</dockerHost>
                    <verbose>true</verbose>
                    <images>
                        <image>
                            <name>${docker.image.prefix}/${docker.image.name}</name>
                            <alias>brewery-ui</alias>
                            <build>
                                <!--copies artifact to docker build dir in target-->
                                <assembly>
                                    <descriptorRef>artifact</descriptorRef>
                                </assembly>
                                <dockerFile>Dockerfile</dockerFile>
                                <tags>
                                    <tag>latest</tag>
                                    <tag>${project.version}</tag>
                                </tags>
                            </build>
                        </image>
                    </images>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>```

【问题讨论】:

  • 如果你把错误记下来,可能是由于:在错误日志中。请将其添加到问题中
  • 看起来提供的代码是为 Java 8 设计的……但您使用的是 Java 9 或更高版本。
  • 另外,请说明您使用的是哪个java版本?
  • 我正在使用 Java 16 和 11
  • @DRASHTI DOBARIYA 在这个错误中没有引起这个简单的通过更改 java-version 或 spring boot 版本来解决。

标签: java spring spring-boot maven


【解决方案1】:

我通过更改 java-version 解决了这个问题。

【讨论】:

  • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
  • 它与lombok及其与正在使用的java版本的兼容性有关。解决方案是升级到最新的 lombok 版本或降级 java 版本(如果可能的话)。
猜你喜欢
  • 2021-11-19
  • 1970-01-01
  • 2021-06-25
  • 2022-10-30
  • 2023-02-10
  • 2019-02-08
  • 2022-01-21
  • 2018-03-20
  • 2022-01-05
相关资源
最近更新 更多