@EnableConfigurationProperties 在springboot启动类添加,当springboot程序启动时会立即加载@EnableConfigurationProperties注解中指定类对象。

@ConfigurationProperties添加在指定类对象上,就会初始化加载到spring容器中。

例如:

@SpringBootApplication
@EnableConfigurationProperties({InitConfig.class})
public class Application {
private static final Logger LOG = LoggerFactory.getLogger(Application.class); public static void main(String[] args) {
SpringApplication app = new SpringApplication(Application.class);
app.setBannerMode(Banner.Mode.OFF);
app.setWebEnvironment(true);
app.run(args);
LOG.info("**************** Startup Success ****************");
}
}
@ConfigurationProperties
public class InitConfig { @PostConstruct //自动执行该方法
public void init() { }
}

springboot 注解@EnableConfigurationProperties @ConfigurationProperties作用的更多相关文章

  1. springboot注解之容器功能

    添加组件 @Configuration.@Bean //以swagger为例 @Configuration(proxyBeanMethods = false) @EnableSwagger2 //使用 ...

  2. springboot之使用@ConfigurationProperties注解

    springboot之使用@ConfigurationProperties注解 代码已经上传至github https://github.com/gittorlight/springboot-exam ...

  3. SpringBoot Shiro 权限注解不起作用

    最近在学习springboot结合shiro做权限管理时碰到一个问题. 问题如下: 我在userRealm中的doGetAuthorizationInfo方法中给用户添加了权限,然后在Controll ...

  4. springboot注解使用说明

    springboot注解 @RestController和@RequestMapping注解 我们的Example类上使用的第一个注解是 @RestController .这被称为一个构造型(ster ...

  5. springboot注解大全

    springboot注解:@Service: 注解在类上,表示这是一个业务层bean@Controller:注解在类上,表示这是一个控制层bean@Repository: 注解在类上,表示这是一个数据 ...

  6. 【转载】springboot注解

    https://blog.csdn.net/yitian_66/article/details/80866571 springboot注解:@Service: 注解在类上,表示这是一个业务层bean@ ...

  7. springBoot系列-->springBoot注解大全

    一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Configuration和@EnableAutoConfiguration ...

  8. SpringBoot注解大全(转)

    原文链接:[springBoot系列]--springBoot注解大全 一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Co ...

  9. SpringBoot注解验证参数

    SpringBoot注解验证参数 废话不多说,直接上表格说明: 注解 作用类型 解释 @NotNull 任何类型 属性不能为null @NotEmpty 集合 集合不能为null,且size大于0 @ ...

随机推荐

  1. linux-安装、启动nginx

    1.下载安装pcre库 pcre是一个正则表达式库,nginx的rewrite模块需要依赖该库. 下载地址:http://www.pcre.org/ wget https://ftp.pcre.org ...

  2. hadoop搭建HA集群之后不能自动切换namenode

    在搭好HA集群之后,想测试一下集群的高可用性,于是先把active的namenode给停掉: hadoop-daemon.sh stop namenode 或者直接kill掉该节点namenode的对 ...

  3. C++——程序的结构

    1.作用域和可见性 1.1 函数原型中的参数其作用域仅在()内.因此参数名称可有可无,但是参数类型需要声明. 1.2 块作用域 在块中声明的标识符其作用域自声明处起,限于块中. 1.3 类作用域 类作 ...

  4. C语言-字符串典型问题分析

    1.典型问题一 下面的程序输出什么为什么? #include <stdio.h>      int main()   {       ] = {};       char src[] =  ...

  5. Radar Installation(利用数据有序化进行贪心选择)

    English appre: an infinite straight line:一条无限长的直线 on the coasting:在海岸线上 Cartesian coordinate system, ...

  6. sql查询 —— 分页

    -- 分页 -- limit -- limit start count (start 显示骑士值,单页数量) select *from student where gender=1 limit 6,3 ...

  7. abb画学号

    MODULE Module2 VAR signaldi signaldi26; VAR signaldi signaldi37; VAR signaldi signaldi48; PROC main2 ...

  8. java基础(四)之this的使用

    作用: 1.使用this调用成员变量和成员函数2.使用this调用构造函数 Person.java: class Person{ String name; //成员变量 void talk(Strin ...

  9. SQL语句分类和语法

    DQL:Data QueryLanguage 数据查询语言 作用:   查询表中的字段 命令:   select         查询 ⑦select 查询列表①from 表1 别名②连接类型 joi ...

  10. HTML的页面结构

    HTML的页面结构 以下为命名的规范: header:标题头部区域的内容(用于页面或页面中的一块区域) footer:标记脚步区域的内容(用于整个页面或页面的一块区域) nav:导航类复杂内容 以上3 ...