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
相关推荐
Seven9717 分钟前
一致性Hash算法:如何实现分布式系统中的高效数据分片?
java
摇滚侠18 分钟前
IDEA 生成 try catch 快捷键
java·ide·intellij-idea
阿旭超级学得完1 小时前
C++11包装器(function和bind)
java·开发语言·c++·算法·哈希算法·散列表
Tiger Z1 小时前
Positron 教程1 --- 用户界面
ide·编程·positron
掉鱼的猫2 小时前
Spring AI 2.0 GA 倒计时:先别急,来看看 Java AI 框架的另一条路
java·openai·agent
Refrain_zc2 小时前
Android 应用内 APK 安装全方案:从静默安装到普通安装的详解
java
正儿八经的少年2 小时前
Spring Boot 两种激活配置方式的作用与区别
java·spring boot·后端
云烟成雨TD3 小时前
Spring AI Alibaba 1.x 系列【52】Interrupts 中断机制:节点执行前后静态中断
java·人工智能·spring
疯狂成瘾者3 小时前
Spring Boot 项目中的 SMTP 邮件验证码服务技术解析
java·spring boot·后端