programing

java.displaces를 클릭합니다.Illogal Access Error: 클래스 lombok.javac.apt를 클릭합니다.Lombok Processor는 com.sun.tools.javac.processing 클래스에 액세스할 수 없습니다.Javac Processing Environment(Javac 처리 환경)

randomtip 2022. 10. 12. 21:22
반응형

java.displaces를 클릭합니다.Illogal Access Error: 클래스 lombok.javac.apt를 클릭합니다.Lombok Processor는 com.sun.tools.javac.processing 클래스에 액세스할 수 없습니다.Javac Processing Environment(Javac 처리 환경)

코딩에 익숙하지 않은 저는 Lombok 플러그인을 사용하여 특정 클래스의 내 필드에 대한 Getters/Setters e.t.c.를 자동으로 생성하려고 합니다.이 경우 다음과 같은 오류가 나타납니다.

오류:

java: java.displaces.Illogal Access Error: 클래스 lombok.javac.apt를 클릭합니다.Lombok Processor(이름 없는 모듈 @0x3b67ef9b)는 클래스 com.sun.tools.javac.processing에 액세스할 수 없습니다.jdk.compiler 모듈이 이름 없는 모듈@0x3b67ef9b로 com.sun.tools.javac.processing을 내보내지 않기 때문에 Javac Processing Environment(모듈 jdk.compiler의 경우)

온라인으로 검색한 결과, 이 에러가 OpenJDK 15의 문제와 관련되어 있는 것을 알 수 있었습니다만, 현재 OpenJDK 16을 사용하고 있기 때문에, 아직 이 에러가 발생하고 있는 것을 알 수 없습니다.

이 스레드에는 https://github.com/rzwitserloot/lombok/issues/2681#issuecomment-748616687라는 솔루션이 있다고 주장하지만 플러그인을 구현한 후에도 아무런 차이가 없는 것 같고 여전히 오류가 발생합니다.

저는 초보자이기 때문에 사소한 실수를 했을 가능성이 높지만, 혹시 제가 부족한 것을 아시는 분이 있으면 알려주세요.

@Data를 사용하는 클래스(Lombok):

import lombok.Data;

@Data
public class Ingredient {

    private final String id;
    private final String name;
    private final Type type;

    public enum Type {
        WRAP, PROTEIN, VEGGIES, CHEESE, SAUCE
    }

}

내 폼 파일:

<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>2.4.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>sia</groupId>
    <artifactId>taco-cloud</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>taco-cloud</name>
    <description>Taco Cloud Project</description>
    <properties>
        <java.version>16</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

적어도 다음 중 하나로 전환합니다.1.18.22수정이 포함된 롬복 버전

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.22</version>
</dependency>

lombok의 마지막 버전을 보려면 search.maven.org에서 다음 링크를 클릭하십시오.

플러그 인을 추가하면 해결할 수 있을 것 같습니다.pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <source>16</source>
        <target>16</target>
        <!--                    <release>16</release>-->
        <fork>true</fork>
        <compilerArgs>
            <arg>--enable-preview</arg>
            <arg>-Xlint:all</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg>
        </compilerArgs>
        <!--for unmappable characters in classes-->
        <encoding>UTF-8</encoding>
        <showDeprecation>true</showDeprecation>
        <showWarnings>true</showWarnings>
        <!--for lombok annotations to resolve-->
        <!--contradictory to maven, intelliJ fails with this-->
        <annotationProcessorPaths>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.16</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>

Java-16과 호환되지 않는 Jdk.compiler 내부 패키지에 대한 Lombok 액세스 솔루션

@FrankyFred는 Lombok을 사용할 수 있는 임시 솔루션을 제공하고 있습니다.https://stackoverflow.com/a/66981165/12586904


제 연구와 이 질문에 대한 다양한 답변으로 볼 때,현재 OpenJDK 16에서는 Lombok실행할 수 있는 방법이 없습니다.그래서...Lombok을 사용하는 다른 방법은 코드에 수동으로 메서드를 넣는 것입니다. https://javabydeveloper.com/lombok-data-annotation/ #:~:text=Data%20Data%20notation%20(%20%40Data%20),as%20well%20as%20a%20 컨스트럭터에서는 이 토픽을 처음 접하는 경우의 간단한 방법을 설명합니다.

「」를 .@Data를 나타냅니다.

@Getter @Setter 
@RequiredArgsConstructor
@ToString 
@EqualsAndHashCode
public class User1 {
  private Long id;
  private String username;
  
}

롬복 @Data주석은 위의 7가지 요구 사항을 모두 생성해야 할 때 추가 주석 사용을 최소화하지만 코드를 실행할 때 기본적으로 동일한 목표를 달성합니다.

저는 이 일에 전문가가 아닙니다만, 롬복의 사용이 막히지만, 그들의 책/튜토리얼이 그것을 이용할 수 있고, 당신은 여전히 책/튜토리얼을 계속하기를 원하기 때문에 다른 대안을 찾을 필요가 있는 사람에게 도움이 되기를 바랍니다.

언급URL : https://stackoverflow.com/questions/66801256/java-lang-illegalaccesserror-class-lombok-javac-apt-lombokprocessor-cannot-acce

반응형