IDEA 2026.1 配置属性识别问题解决

IDEA 2026.1 升级后 Cannot resolve configuration property 'asc.wx.baseUrl'90% 是注解处理器关闭、配置元数据没生成、dev 多环境未关联、Spring 索引异常,按下面步骤一键修复:

一、优先开启注解处理器(2026.1 默认常关闭)

File → Settings → Build, Execution, Deployment → Compiler → Annotation Processors
  • 勾选 Enable annotation processing
  • 勾选 Obtain processors from project classpath
  • 应用保存 → 重启 IDEA

二、pom 必须引入配置元数据依赖(Spring Boot 配置提示核心)

xml

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

引入后 Maven Reload 项目

三、检查 dev 环境配置绑定

  1. application-dev.yml 右键 → Mark as Spring Configuration File
  2. 主配置 application.yml 确认激活 dev:

yaml

spring:
  profiles:
    active: dev
  1. 多模块项目:每个子模块都要加 processor 依赖

四、配置类写法(asc.wxjs 前缀)

java

运行

@Component
@ConfigurationProperties(prefix = "asc.wx")
public class WxjsConfig {
    private String baseUrl;
    // getter/setter
}

启动类加上扫描(新版必加):

java

运行

@SpringBootApplication
@ConfigurationPropertiesScan

五、清理 IDEA 缓存 + 重建索引(2026.1 高频索引 bug)

File → Invalidate Caches...

  • 勾选所有选项 → Invalidate and Restart重启后执行:mvn clean compile,生成 META-INF/spring-configuration-metadata.json
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值