美文网首页
idea未生成springboot的spring-configu

idea未生成springboot的spring-configu

作者: 码农梦醒 | 来源:发表于2020-02-21 15:42 被阅读0次

pom.xml文件中加入spring-boot-configuration-processor依赖

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

idea启用enable annotation processing

image.png

编写了正确的属性配置类

package com.pzy.component.webstarter.support.configuration;

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

/**
 * @author pzy
 * @date 2018/11/18
 */
@ConfigurationProperties(prefix = "component.web", ignoreInvalidFields = true)
public class WebStarterProperties {

    private GlobalExceptionProperties globalException;

    public GlobalExceptionProperties getGlobalException() {
        return globalException;
    }

    public void setGlobalException(GlobalExceptionProperties globalException) {
        this.globalException = globalException;
    }
}

项目pom文件,编译插件配置 (重点)

<!-- Compiler 插件, 设定 JDK 版本 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <showWarnings>true</showWarnings>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${mapstruct.version}</version>
                        </path>
                        <path>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-configuration-processor</artifactId>
                            <version>${spring-boot.version}</version>
                        </path>
                    </annotationProcessorPaths>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

重新编译项目

相关文章

网友评论

      本文标题:idea未生成springboot的spring-configu

      本文链接:https://www.haomeiwen.com/subject/ndrknctx.html