SpringBoot Configuration Annotation Processor not configured
一、Spring boot自定义配置实现自动提示
@ConfigurationProperties
的作用: 让JavaBean中属性值要和配置文件进行映射
@Getter
@Setter
@ConfigurationProperties(prefix = "jwt")
public class JwtProperties {/*** JWT加解密使用的密钥*/private String secret;/*** JWT的过期限时间*/private String expiration;/*** JWT负载中拿到开头*/private String tokenHead;/*** JWT存储的请求头*/private String tokenHeader;}
二、在启动类中加入@EnableConfigurationProperties 注解
@EnableConfigurationProperties 注解的作用:让使用了 @ConfigurationProperties 注解的类生效。
@EnableConfigurationProperties({JwtProperties.class})
@SpringBootApplication
public class SeadogAdminApplication {public static void main(String[] args) {SpringApplication.run(SeadogAdminApplication.class, args);}
}
三、idea中会提示SpringBoot Configuration Annotation Processor not configured的错误
四、解决方法
您在使用@ConfigurationProperties注解时可以使用spring-boot-configuration-processor jar 轻松地从带有注释的项目中生成自己的配置元数据文件。该jar包含一个Java注释处理器,在您的项目被编译时会被调用。要使用处理器,请包含对的依赖spring-boot-configuration-processor。
1.添加spring-boot-configuration-processor的依赖
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional>
</dependency>
重新buil了项目,你会发现问题还没有解决,idea还是提示:SpringBoot Configuration Annotation Processor not configured的错误。
2.在maven-compiler-plugin内的annotationProcessorPaths中添加相应path
<pluginManagement><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding><annotationProcessorPaths><path><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><version>${springboot.version}</version></path></annotationProcessorPaths></configuration></plugin></plugins>
</pluginManagement>
3.maven-clean 重新build一下项目,会在target->classes->META-INF目录下生成配置元数据文件:spring-configuration-metadata.json
打开spring-configuration-metadata.json文件
{"groups": [{"name": "jwt","type": "com.seadog.common.security.config.JwtProperties","sourceType": "com.seadog.common.security.config.JwtProperties"}],"properties": [{"name": "jwt.expiration","type": "java.lang.String","description": "JWT的过期限时间","sourceType": "com.seadog.common.security.config.JwtProperties"},{"name": "jwt.secret","type": "java.lang.String","description": "JWT加解密使用的密钥","sourceType": "com.seadog.common.security.config.JwtProperties"},{"name": "jwt.token-head","type": "java.lang.String","description": "JWT负载中拿到开头","sourceType": "com.seadog.common.security.config.JwtProperties"},{"name": "jwt.token-header","type": "java.lang.String","description": "JWT存储的请求头","sourceType": "com.seadog.common.security.config.JwtProperties"}],"hints": []
}
4.在application.yml中测试
SpringBoot Configuration Annotation Processor not configured相关推荐
- SpringBoot项目中获取yml文件的属性时实体属性类出现Spring Boot Configuration Annotation Processor not found in classpath
1.SpringBoot项目的项目结构如下: 2.属性实体类 上面出现了Spring Boot Configuration Annotation Processor not found in clas ...
- Spring Boot——[Spring Boot Configuration Annotation Processor not found in classpath]解决方案
问题描述 使用Spring Boot开发的过程中,写读取Properties配置文件的配置类时提示Spring Boot configuration annotation processor not ...
- 解决spring boot1.5以上版本@ConfigurationProperties提示“Spring Boot Configuration Annotation Processor not..
Springboot1.5以上版本,在使用 @ConfigurationProperties注解的时候会提示"Spring Boot Configuration Annotation Pro ...
- spring boot configuration annotation processor not found in classpath问题解决
1.点击提示的右上角工具图标 2.取消show notification panel勾选项. 转载于:https://www.cnblogs.com/debug-zheng/p/11074535.ht ...
- spring Boot Configuration Annotation Processor not fount in classpath
在pox在添加: <!--生成自定义配置的元数据信息--> <dependency><groupId>org.springframework.boot</gr ...
- 项目可以运行但是在当前controller类顶部出现Spring Boot Configuration Annotation Proces
学习pringBoot项目时,在写controller时发现,项目可以运行但是在当前controller类顶部出现Spring Boot Configuration Annotation Proces ...
- Springboot@Configuration和@Bean详解
Springboot@Configuration和@Bean详解 一.@Configuration @Target({ElementType.TYPE}) @Retention(RetentionPo ...
- 关于Unable to load annotation processor factory 的故障
2019独角兽企业重金招聘Python工程师标准>>> 导入一个项目的时候,如果提醒以下错误,可参考https://github.com/excilys/androidannotat ...
- Spring Boot之 Configuration Annotation Proessor not found in classpath解决方法
出现spring boot Configuration Annotation Proessor not found in classpath的提示是在用了@ConfigurationPropertie ...
最新文章
- 单据自动转换并审核的方法示例
- 抛弃注意力,类Transformer新模型实现新SOTA
- 51nod 1282 时钟
- 两个特征是独立好还是正相关好_长文之详解机器学习的数据特征选择问题
- php与c语言流程控制语句,小蚂蚁学习C语言(7)——C语言流程控制之if
- linux指令:软连接与历史命令
- xadmin与admin设置
- 什么是LAMP?LAMP有什么优势?
- python图合并_Python-numpy实现灰度图像的分块和合并方式
- 做了 7 年开源数据库开发,我学到了什么?
- Excel小技巧总结,工作中超实用
- php url 转码,php url中文转码的方法
- Android 热更新Robust 浅析
- 【历史上的今天】7 月 18 日:英特尔成立;万维网上传了第一张照片;eBay 分拆 PayPal
- 业务持续计划(BCP,Business Continuity Plan)
- 【Excel函数】相对定位与绝对定位
- 【数据可视化应用】IDW插值计算实战案例(附Python和R语言代码)
- list object has no attribute ZScan_书香家庭NO.31 | 成长路上飘书香
- 在J2EE项目中集成快钱支付接口
- kubernetes的部署架构以及工作原理