@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. AcWing 1022. 宠物小精灵之收服 二维费用背包

    #include<iostream> using namespace std ; ; int f[N][N]; int V1,V2,n; int main() { cin>>V ...

  2. 【Python】字符串处理函数

  3. SSM项目中的.tld文件是什么,有什么作用?怎么自定义tld文件

    原文链接:https://www.cnblogs.com/guaishoubiubiu/p/8721277.html TLD术语解释:标签库描述文件,如要在JSP页面中使用自定义JSP标签,必须首先定 ...

  4. Leetcode 面试题 01.01. 判定字符是否唯一

    实现一个算法,确定一个字符串 s 的所有字符是否全都不同. 示例 1: 输入: s = "leetcode"输出: false 示例 2: 输入: s = "abc&qu ...

  5. 搭建Hexo实现个人网站详细教程

    全网最全小白搭建Hexo+Gitee/Coding/Github 全网最全小白搭建Hexo+Gitee/Coding/Github 本站内容已全部转移到https://www.myyuns.ltd,具 ...

  6. 使用 NuGet 包管理器在 Visual Studio 中安装和管理包

    https://docs.microsoft.com/zh-cn/nuget/consume-packages/install-use-packages-visual-studio 通过 Window ...

  7. Android开发模拟器(虚拟机)的连接等操作

    前10天一直在解决android开发环境的问题,我将Androidstudio下载并安装好之后,进入IDE之后,下载AVDmanger中的虚拟机以及SDK等等.之后发现并不能运行虚拟机,根本无法打开虚 ...

  8. 【Html】Html基本标记

    <!doctype html> <html> <head> <!--mata 元信息标记--> <meta charset="utf-8 ...

  9. UVA 12097 Pie(二分答案)

    题目链接: 这道题虽然不是一道典型的二分答案题,但同样也可以用二分答案来做. 来二分面积为$area$的派,然后看看条件是否矛盾. 与其矛盾的便是$f+1$个人是否每个人都会有. 一个半径为$r$的派 ...

  10. C#中通过SendARP读取MAC地址

    C#中通过SendARP读取MAC地址: using System.Runtime.InteropServices; publicstaticstring GetMacBySendARP(string ...