Intellij Idea 如何按照指南“重新运行Sping Boot Configuration Annotation Processor以更新生成的元数据”?

wmvff8tz  于 2022-12-11  发布在  其他
关注(0)|答案(1)|浏览(529)

例如,文件DataSourceConfig.java

package com.apress.demo;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "jdbc")
public class DataSourceConfig {
    private String driver;
    private String url;
    private String username;
    private String password;

    @Override
    public String toString() {
        return "DataSourceConfig [driver=" + driver + ", url=" + url + ", username=" + username + "]";
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

}

这通知怎么办?

owfi6suc

owfi6suc1#

它只是提醒您,在您进行更改并重新运行注记处理器之前,配置属性将不可用
您可以通过以下方式在IntelliJ中启用注解处理器:

  • 单击文件
  • 点击设置
  • 在左上角的小搜索框中,搜索“Annotation Processors”
  • 选中“启用注解处理”
  • 单击确定



在pom.xml中添加依赖项

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <optional>true</optional>
</dependency>

配置注解处理器并添加注解@Configuration

相关问题