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

效果图

相关推荐
一 乐2 小时前
家政服务管理系统|基于springboot + vue家政服务管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·家政服务管理系统
IT_陈寒2 小时前
Vite热更新失效?可能你在用Windows
前端·人工智能·后端
椰椰椰耶3 小时前
[SpringCloud][14]OpenFeign参数传递方法
后端·spring·spring cloud
onething3653 小时前
Spring Boot + Spring AI 从入门到实战:7天转型计划 Day 3 —— 消息表设计 + 级联删除 + 事务管理
人工智能·后端
荣江3 小时前
Hermes Agent 代码仓库打包工具使用指南(repomix-rs 高性能版)
后端
王某某人3 小时前
LangChain4j 入门:Java 程序员的第一个 AI 对话程序
人工智能·后端
码农刚子3 小时前
从零开始:在 Windows 服务器上部署 Node.js 项目(小白实战教程)
后端·node.js
Cache技术分享3 小时前
435. Java 日期时间 API - Clock 灵活获取当前时间
前端·后端
浩子coding3 小时前
通过 Spring AI Alibaba 源码,看如何玩转 ReAct 智能体范式
人工智能·后端
星浩AI4 小时前
合规项目大模型如何部署?硬件选型 + vLLM/LMDeploy 实战
pytorch·后端·llm