@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. 创建JDBC六个步骤

    JDBC库中所包含的API通常与数据库使用于: 连接到数据库 创建SQL或MySQL语句 在数据库中执行SQL或MySQL查询 查看和修改数据库中的数据记录 创建JDBC应用程序 建立一个JDBC应用 ...

  2. selenium自动化之加载浏览器配置文件

    化环境:python3.6 + selenium3 当我们做自动化的时候,如果不做任何配置的话打开的浏览器默认是不加载我们的浏览器配置文件的,下面我们来说说如何加载配置文件: 首先不管使用的是火狐浏览 ...

  3. 12day echo {1..100} << 三剑客命令

    04. 直接编辑文件命令方法 a 如何直接在文件中添加单行内容 echo "oldboy" >>/oldboy/oldboy.txt 补充: echo命令用法说明: 0 ...

  4. P1582 倒水(贪心 + lowbbit)

    https://www.luogu.com.cn/problem/P1582 #include <bits/stdc++.h> using namespace std; #define i ...

  5. bzoj3626: [LNOI2014]LCA (树链剖分)

    很神奇的方法 感觉是有生之年都想不到正解的这种 考虑对i 到根的节点权值 + 1,则从根到z的路径和就是lca(i,z)的深度 所以依次把0 ~ n - 1的点权值 + 1 对于询问[l, r] 这个 ...

  6. 题解【SP2713】GSS4 - Can you answer these queries IV

    题目描述 You are given a sequence \(A\) of \(N(N \leq 100,000)\) positive integers. There sum will be le ...

  7. 题解【POJ1160】Post Office

    [POJ1160]Post Office Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 22362 Accepted: 1208 ...

  8. leetcode78.子集➕90.子集2

    78子集 dfs dfs1: 和全排列的区别就是对于当前考察的索引i,全排列如果不取i,之后还要取i,所以需要一个visited数组用来记录.对于子集问题如果不取i,之后也不必再取i. 单纯递归回溯 ...

  9. thinkphp的模型操作

    先开个坑 WHERE篇 1, 模糊查询    where['keyword'] = [ 'like' , '%test%'] 2,   不等于,大于 ,小于 EQ 等于(=)NEQ 不等于(<& ...

  10. Multisim 中的一些快捷键

    1.镜像 Alt + Y 2.左转90° Ctrl + L 3.右转90° Ctrl + R