0
点赞
收藏
分享

微信扫一扫

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

i奇异 2023-10-12 阅读 43

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

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

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;
}

sys:
  pe:
    dingtalk:
      robot-url: xxx
      secret: xxx

 

举报

相关推荐

0 条评论