【问题标题】:lombok annotation龙目岛注解
【发布时间】:2017-01-26 19:55:43
【问题描述】:

我是龙目岛的新手,我有一个项目我已经做了一段时间了。在我更改操作系统之前,一切都运行良好(保留 Bitbucket 上的代码)。现在我收到一个错误

org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.beans.factory.BeanFactory

可能是 lombok 版本的问题或 ide 的问题。我使用的是 netbean 8

【问题讨论】:

  • 错误是什么?此外,这个注解与 Spring Boot 无关,它是一个 Lombok 注解。

标签: spring spring-boot lombok


【解决方案1】:

在你的类路径中使用最新的 lombok 版本的 jar 来使用 @RequiredArgsConstructor 中的 @Autowired 支持。为避免出现 ide 警告,请为您的 ide 使用 lombok 插件,记得启用注解处理。

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

【讨论】:

    【解决方案2】:
       *added this after making sure i have the latest version of lombok dependecy* <plugin>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
            <version>1.18.0.0</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>delombok</goal>
                    </goals>
                    <configuration>
                        <sourceDirectory>src/main/java</sourceDirectory>
                        <addOutputDirectory>false</addOutputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-02
      • 2021-03-27
      • 2015-10-18
      • 1970-01-01
      • 2016-10-08
      • 2011-06-19
      • 2017-01-16
      • 2015-04-04
      相关资源
      最近更新 更多