@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 ...
随机推荐
- mysql学习 | LeetCode数据库简单查询练习
力扣:https://leetcode-cn.com/ 力扣网数据库练习:https://leetcode-cn.com/problemset/database/ 文章目录 175. 组合两个表 题解 ...
- 切图崽的自我修养-[ES6] 迭代器Iterator浅析
Iterator 这真是毅种循环 Iterator不是array,也不是set,不是map, 它不是一个实体,而是一种访问机制,是一个用来访问某个对象的接口规范,为各种不同的数据结构提供统一的访问机制 ...
- 从零开始:微信小程序新手入门宝典《一》
为了方便大家了解并入门微信小程序,我将一些可能会需要的知识,列在这里,让大家方便的从零开始学习: 一:微信小程序的特点 张小龙:张小龙全面阐述小程序,推荐通读此文: 小程序是一种不需要下载.安装即可使 ...
- canvas菜鸟基于小程序实现图案在线定制功能
前言 最近收到一个这样的需求,要求做一个基于 vue 和 element-ui 的通用后台框架页,具体要求如下: 要求通用性高,需要在后期四十多个子项目中使用,所以大部分地方都做成可配置的. 要求做成 ...
- Vue.js快速介绍-超级马里奥像素艺术
原文出处:Quick Introduction to Vue.js - Super Mario Pixel Art ::代码我已经归纳在github上:[vue2-pixel-art]::::__查看 ...
- python爬虫---污言污语网站数据采集
代码: import requests from lxml import etree headers = { "user-agent": "Mozilla/5.0 (Wi ...
- java中Object类的finalize的用法
Object类的finalize的用法: 马克-to-win:java当中有个垃圾回收机制,具体说,就是当一些对象被创建使用之后若不再使用的话{比如(i)对象被置成null.(ii)局部对象(无需置成 ...
- Win7运行net5 wpf条件
Win7运行net5 wpf条件 win7 sp1 dotnet-runtime-5 vc_redist KB2999226 KB4457144 Tips:官网条件最后一个最坑爹,KB2533623不 ...
- 在Wireshark中使用过滤器——显示过滤器
在Wireshark运行过程中选择搜索(Ctrl-F),第一个默认的搜索选项就是显示过滤器. 显示过滤器用于捕获文件,用来告诉Wireshark只显示那些符合过滤条件的数据包. 显示过滤器比捕获过滤器 ...
- matplotlib---设置坐标轴
import matplotlib.pyplot as plt import numpy as np # 一维数组, 元素为从-3到3之间均匀地产生50个点 x = np.linspace(-3, 3 ...