spring boot 配置文件提示自定义配置属性
1、引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
2、在属性类上添加注解
@ConfigurationProperties(prefix="server")
public class ServerProperties {
private String name;
private Host host;
// ... getter and setters
private static class Host {
private String ip;
private int port;
// ... getter and setters
}
}
本质是生成json进行提示:

spring boot 配置文件提示自定义配置属性的更多相关文章
- Spring Boot 2 使用自定义配置
在application.yml定义配置后,可以使用Environment来读取配置,也可以使用@Value注解让业务代码去读取配置.如果属性较多,可以定义属性映射对象. 开发环境:IntelliJ ...
- spring boot配置文件application.properties配置JPA以及数据源
1.application.properties配置jpa模板 spring.datasource.url=jdbc:mysql://localhost:3306/springboottest?use ...
- spring boot配置文件、日志配置和代码的多环境配置
一般项目都逃不掉开发.测试和生产这三套环境,如果每次给这三套环境打包都去改配置,累死不说,还一不留心就出差错.倒不如每套环境各给一套配置来的轻松.上代码: 1.通用配置放在application.pr ...
- spring boot加载自定义配置
1.通过@Value 配置文件中 wechat: ssh: host: 192.0.1.1 port: 22 加载类 @Component @Data public class SftpConfig ...
- Spring Boot 系列(三)属性配置&自定义属性配置
在使用spring boot过程中,可以发现项目中只需要极少的配置就能完成相应的功能,这归功于spring boot中的模块化配置,在pom.xml中依赖的每个Starter都有默认配置,而这些默认配 ...
- Spring Boot 配置文件和命令行配置
Spring Boot 属于约定大于配置,就是说 Spring Boot 推荐不做配置,很多都是默认配置,但如果想要配置系统,使得软件符合业务定义,Spring Boot 可以通过多种方式进行配置. ...
- Spring Boot学习记录03_一些属性配置文件
转自:http://blog.didispace.com/springbootproperties/ 多环境配置(这个地方跟maven的profile配置有点类似) 我们在开发Spring Boot应 ...
- Spring Boot实践——用外部配置填充Bean属性的几种方法
引用:https://blog.csdn.net/qq_17586821/article/details/79802320 spring boot允许我们把配置信息外部化.由此,我们就可以在不同的环境 ...
- Spring Boot☞ 配置文件详解:自定义属性、随机数、多环境配置等
自定义属性与加载 我们在使用Spring Boot的时候,通常也需要定义一些自己使用的属性,我们可以如下方式直接定义: application-dev.yml com.didispace.blog: ...
随机推荐
- table显示json数据传递
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 【JS】Intermediate8:jQuery:AJAX
1.$.ajax is the main method, allowing you to manually construct your AJAX request 2.eg: gets some da ...
- Storm系列(九)架构分析之Supervisor-同步Nimbus的事件线程
Supervisor由三个线程组成,一个计时器线程和两个事件线程. 计时器线程负责维持心跳已经更新Zookeeper中的状态,还负责每隔一定的时间将事件线程需要执行的事件添加到其对应的队列中. 两个事 ...
- HW3.22
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- ScheduledExecutorFactoryBean忽略异常继续执行
ScheduledExecutorFactoryBean忽略异常继续执行 程序中有一个定时任务,每10分钟把满足条件的任务从一个表迁移到另一张表,程序启动的时候数据库异常了一段时间,之后数据库恢复了. ...
- hibernate三级缓存介绍
hibernate缓存机制:分为三种:1.一级缓存(session级别缓存,同一session中不会重复发出sql,默认会实现)2.二级缓存(跨session的缓存,不同session会从同一缓存中取 ...
- JAVA_3lesson
程序设计守则 为了增加程序的可扩展性,维护性.可以采用interface, abstract 可以抽象出来:共同的方法,属性 开发系统时,主体构架使用接口,接口构成了系统的骨架. 要遵循开 ...
- POJ 2728 Desert King
Description David the Great has just become the king of a desert country. To win the respect of his ...
- linux命令之more
转自:http://www.cnblogs.com/peida/archive/2012/11/02/2750588.html more命令,功能类似 cat ,cat命令是整个文件的内容从上到下显示 ...
- ios7自带的晃动效果
ios7自带的晃动效果 by 伍雪颖 - (void)registerEffectForView:(UIView *)aView depth:(CGFloat)depth; { UIInterpola ...