spring boot自定义配置时在yml文件输入有提示

自定义一个配置类,然后在yml文件具体配置值时,一般不会有提示,这个解决这个问题

依赖

复制代码
        <!--自定义配置类,在yml文件写的时候会有提示-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

重新刷一下Pom依赖

自定义配置类

复制代码
package com.example.redissontest.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

//以下注解是把改配置类注入到容器中
@ConfigurationProperties(prefix = "sys.pe.dingtalk")
@Component
@Data
public class DingTalkConfig {
    private String robotUrl;
    private String secret;
}

重新build一下加入依赖所在的项目

yml文件配置

复制代码
sys:
  pe:
    dingtalk:
      robot-url: xxx
      secret: xxx

效果图

相关推荐
UrbanJazzerati1 天前
Salesforce User Agent Flow 授权流程详解
后端
JavaGuide1 天前
Spring Boot 3.3+Java 21+Spring AI+RustFS打造的智能面试平台开源啦!
spring boot·后端
最贪吃的虎1 天前
Java基础之集合(3/8)
java·后端
回家路上绕了弯1 天前
熔断限流实战指南:分布式系统的稳定性守卫
分布式·后端
Coder_Boy_1 天前
基于SpringAI的企业级智能教学考试平台页面交互模块规划
人工智能·spring boot
计算机毕设VX:Fegn08951 天前
计算机毕业设计|基于springboot + vue出行旅游安排系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·课程设计
AskHarries1 天前
AI 是如何识别 MCP 工具,并在合适的时候触发调用的?
后端
刀法如飞1 天前
API接口安全设计:动态盐值与签名机制的实现与剖析
java·前端·后端
又是忙碌的一天1 天前
Spring IOC:依赖注入和bean的生命周期
java·后端·spring
计算机学姐1 天前
基于SpringBoot的个人健康管理系统【2026最新】
java·spring boot·后端·mysql·spring·intellij-idea·mybatis