SpringBoot让yml,properties配置文件有代码提示

一、需要的注解

@ConfigurationProperties 配置属性文件,需要指定前缀 prefix
@Component是采用组件

二、POM依赖

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

三、配置类


@Data
@Component
@ConfigurationProperties(prefix = "person")
public class JiuxianProperties {
    
    
    private String name;
    private int age;
    private boolean boos;
    @Data
    static class Dog {
    
    
        private String name;
        private int age;
    }
}
@SpringBootApplication
public class SpringbootYmlDemoApplication {
    
    

    public static void main(String[] args) {
    
    
        SpringApplication.run(SpringbootYmlApplication.class, args);
    }
}

猜你喜欢

转载自blog.csdn.net/ayunnuo/article/details/108521281
今日推荐