代码之家  ›  专栏  ›  技术社区  ›  Georgi Michev

将lombok插件添加到intellij

  •  1
  • Georgi Michev  · 技术社区  · 6 年前

    Intellij不识别Spring注释,我认为它与Lombok有关。

    我在Intellij设置中添加了插件并启用了注释处理

    我在使用Maven,我有这种依赖性

    dependency>
           <groupId>org.projectlombok</groupId>
           <artifactId>lombok</artifactId>
           <scope>provided</scope>
    </dependency>
    

    仍然Intellij无法识别SLF4J和Spring注释

    4 回复  |  直到 6 年前
        1
  •  1
  •   dkb Santhosh Reddy Mandadi    6 年前

    按照步骤操作
    1。构建Spring应用程序,如中所述: https://spring.io/guides/gs/spring-boot/

    1. 在Intellij中安装Lombok(检查 compatibility 使用您的Intellij想法版本)

    lombok installation

    1. 作为依赖项添加到(pom.xml/build.gradle/other build files)
    <dependency>
       <groupId>org.projectlombok</groupId>
       <artifactId>lombok</artifactId>
       <scope>provided</scope>
    </dependency>
    
    1. 建设项目

    2. 在Intellij中启用注释处理(每次导入新项目时都必须执行此操作,如果希望在默认情况下启用它,请执行中提到的步骤 this 所以OP.
      File γ Other Settings γ Default Settings ,在导入项目之前,导航到编译器设置、注释处理并启用此选项。

    如果你仍然面临问题,那就做一次。 文件 / Invalidate caches / Invalidate and restart

    annotation Processor

    就是这样。

        2
  •  0
  •   praneet drolia    6 年前

    转到intellij中的首选项并安装lombok插件。

        3
  •  0
  •   nbirla    6 年前

    您还需要将lombok插件安装到intellij。

    Files->Settings->Plugins->Click on Browse repositories->Search for Lombok->Install plugin->Restart Intellij
    
        4
  •  0
  •   Georgi Michev    6 年前

    我的pom.xml看起来像这样

    <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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>
    
    <properties>
        <spring-data-dynamodb.version>4.5.0</spring-data-dynamodb.version>
        <aws-java-sdk.version>1.11.64</aws-java-sdk.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
    
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc7</artifactId>
        </dependency>
    
        <dependency>
            <groupId>com.shutterfly.springboard</groupId>
            <artifactId>springboard-starter-service-minimal</artifactId>
        </dependency
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-aws</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.amazonaws</groupId>
                    <artifactId>aws-java-sdk-cloudformation</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-dynamodb</artifactId>
        </dependency>
    
        <dependency>
            <groupId>com.github.derjust</groupId>
            <artifactId>spring-data-dynamodb</artifactId>
            <version>${spring-data-dynamodb.version}</version>
        </dependency>
    
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>dynamodb-lock-client</artifactId>
            <version>1.0.0</version>
        </dependency>
    
        <dependency>
            <groupId>org.modelmapper</groupId>
            <artifactId>modelmapper</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
    
        <dependency>
            <groupId>com.shutterfly.springboard</groupId>
            <artifactId>springboard-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    
        <dependency>
            <groupId>com.shutterfly.springboard</groupId>
            <artifactId>springboard-functional-test</artifactId>
            <scope>test</scope>
        </dependency>
    
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>3.1.0</version>
            <scope>test</scope>
        </dependency>
    
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.10.0</version>
            <scope>test</scope>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
        </dependency>
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>4.37</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.8.1</version>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
     </project>
    

    我不知道我错过了什么。也试图重建