@ConfigurationProperties(prefix = "server-options") 抛出 SpringBoot Configuration Annotation Processor not configured 错误
说明
spring-boot-configuration-processor 包的作用是自动生成 META-INF/spring-configuration-metadata.json 文件,而这个 json 文件可以为我们在配置 application.yml 文件时提供智能提示、自动补全、注释、跳转到 java 代码(ctrl+鼠标左键)的功能。
这样一来,在开发过程中就会避免写错配置项的问题,也可以增加编码流畅感
完美集成步骤
在 pom.xml 的 dependencies 节点中加入
spring-boot-configuration-processor包的 maven 依赖<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
<version>2.5.2</version>
</dependency>
检查有没有在 pom.xml 中配置
build/plugins/[artifactId=maven-compiler-plugin]/configuration/annotationProcessorPaths
如果没有配置,可以跳到第 3 点了
如果配置了,那么一定要在annotationProcessorPaths加入spring-boot-configuration-processor包的path节点,如下:<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>2.5.2</version>
</path>
注意
version和dependencies节点中的一致,可以在properties节点中声明该包的版本号,然后在以上两个地方引用声明的变量编写自己的 XXProperty,如下:
package com.example.springboottests; import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.stereotype.Component; @Getter
@Setter
@Component
@ConfigurationProperties(prefix = "server-options")
public class ServerProperty {
/**
* 名称
*/
private String name; /**
* 其他配置
*/
@NestedConfigurationProperty
private ServerOtherProperty api; @Getter
@Setter
public static class ServerOtherProperty {
/**
* 标题
*/
private String title;
}
}
完毕,现在可以去
resources/application.yml查看效果了

必读的注意事项
- 每次修改
ServerProperty中的内容时,必须要 rebuild 项目,因为他是通过编译帮助我们自动生成META-INF/spring-configuration-metadata.json文件,所以如果不 rebuild,json 文件内容就不会变。 - 如果不生效,可以自己看下是不是修改了 pom.xml 但没有点击右上角的刷新按钮,或者删除
target目录再 build 试试
@ConfigurationProperties(prefix = "server-options") 抛出 SpringBoot Configuration Annotation Processor not configured 错误的更多相关文章
- idea中的springboot+gradle项目报错springboot configuration annotation processor not found in classpath
idea中的springboot项目,打开某个类run.halo.app.config.properties.HaloProperties.java,报错(使用gradle编译): springboo ...
- SpringBoot中使用@ConfigurationProperties提示:Configuration Annotation Processor not found in classpath
问题 Springboot1.5以上版本,在使用 @ConfigurationProperties注解的时候会提示Spring Boot Configuration Annotation Proces ...
- 解决spring boot1.5以上版本@ConfigurationProperties提示“Spring Boot Configuration Annotation Processor not.."
Springboot1.5以上版本,在使用 @ConfigurationProperties注解的时候会提示“Spring Boot Configuration Annotation Processo ...
- PHP 的异常处理、错误的抛出及回调函数等面向对象的错误处理方法
PHP 的异常处理.错误的抛出及回调函数等面向对象的错误处理方法: http://www.jb51.net/article/32498.htm http://www.cnblogs.com/hongf ...
- 论如何优雅的抛出SpringBoot注解的异常
平时我们在写代码的时候肯定要进行很多参数验证,最开始的时候我们一般都是这样处理的 如下图 看起来好像也没什么,但是 如果参数多了呢?你就会看到这样的校验 OMG!!! 有没有感觉稍微有点视觉 ...
- CocoaPods 抛出[!] Unable to satisfy the following requirements: 错误
今天使用CocoaPods管理ReactiveCocoa,抛出以下错误 [!] Unable to satisfy the following requirements: - `ReactiveCoc ...
- 使用@ConfigurationProperties注解 提示 “Spring Boot Configuration Annotation Processor not found in classpath ”
解决方案: 在 pom.xml 添加依赖 <dependency> <groupId>org.springframework.boot</groupId> < ...
- spring boot configuration annotation processor not found in classpath
<dependency> <groupId> org.springframework.boot </groupId> <artifactId> spri ...
- 解决Spring Boot Configuration Annotation Processor not found in classpath
问题截图: 解决方式: 在pom.xml文件中添加这些依赖 <dependency> <groupId>org.springframework.boot</groupId ...
随机推荐
- 决策树算法4:CHAID
原理: 其中 n = a+b+c+d 卡方计算(例子)使用 sklearn完成 data.csv中的部分数据 #如何使用卡方检测相关度 from sklearn.feature_selection i ...
- 《深入理解ES6》笔记——扩展对象的功能性(4)
变量功能被加强了.函数功能被加强了,那么作为JavaScript中最普遍的对象,不加强对得起观众吗? 对象类别 在ES6中,对象分为下面几种叫法.(不需要知道概念) 1.普通对象 2.特异对象 3.标 ...
- python-使用函数求特殊a串数列和
给定两个均不超过9的正整数a和n,要求编写函数fn(a,n) 求a+aa+aaa++⋯+aa⋯aa(n个a)之和,fn须返回的是数列和 函数接口定义: 1 fn(a,n) 2 其中 a 和 n 都是用 ...
- 主线程中的Looper.loop()为什么不会造成ANR
引子: 正如我们所知,在android中如果主线程中进行耗时操作会引发ANR(Application Not Responding)异常. 造成ANR的原因一般有两种: 当前的事件没有机会得到处理(即 ...
- C2678 二进制“<”: 没有找到接受“const ***”类型的左操作数的运算符解决办法
正确代码如下:#include<iostream> #include<string> #include<map> using namespace std; /*仿函 ...
- 移动端页面中点击input输入框的时候弹出的键盘将输入框挡住的问题
使用的是vux框架, 以为是框架问题, 后来发现是把当前页面的高度写死为了height:200%: 只要把高度去掉就能让页面自动弹到输入框的上方:
- python"温度转换"实例编写
介绍 实现华氏度和摄氏度之间的转换. 代码: #TempCovert.py TempStr = input("请输入带有符号的温度值") if TempStr[-1] in [&q ...
- python循环与基本数据类型内置方法
今天又是充满希望的一天呢 一.python循环 1.wuile与else连用 当while没有被关键'break'主动结束的情况下 正常结束循环体代码之后会执行else的子代码 "" ...
- Python 国家地震台网中心地震数据集完整分析、pyecharts、plotly,分析强震次数、震级分布、震级震源关系、发生位置、发生时段、最大震级、平均震级
注意,本篇内容根据我老师布置的数据分析作业展开.请勿抄袭,后果自负! 前情提要 编写这篇文章是为了记录自己是如何分析地震数据集,使用模块,克服一系列 \(bug\) 的过程.如果你是 \(python ...
- Linux中信号量的实现
如果一个任务获取信号量失败,该任务就必须等待,直到其他任务释放信号量.本文的重点是,在Linux中,当有任务释放信号量之后,如何唤醒正在等待该信号量的任务. 信号量定义如下: struct semap ...