springboot 注解@EnableConfigurationProperties @ConfigurationProperties作用
@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作用的更多相关文章
- springboot注解之容器功能
添加组件 @Configuration.@Bean //以swagger为例 @Configuration(proxyBeanMethods = false) @EnableSwagger2 //使用 ...
- springboot之使用@ConfigurationProperties注解
springboot之使用@ConfigurationProperties注解 代码已经上传至github https://github.com/gittorlight/springboot-exam ...
- SpringBoot Shiro 权限注解不起作用
最近在学习springboot结合shiro做权限管理时碰到一个问题. 问题如下: 我在userRealm中的doGetAuthorizationInfo方法中给用户添加了权限,然后在Controll ...
- springboot注解使用说明
springboot注解 @RestController和@RequestMapping注解 我们的Example类上使用的第一个注解是 @RestController .这被称为一个构造型(ster ...
- springboot注解大全
springboot注解:@Service: 注解在类上,表示这是一个业务层bean@Controller:注解在类上,表示这是一个控制层bean@Repository: 注解在类上,表示这是一个数据 ...
- 【转载】springboot注解
https://blog.csdn.net/yitian_66/article/details/80866571 springboot注解:@Service: 注解在类上,表示这是一个业务层bean@ ...
- springBoot系列-->springBoot注解大全
一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Configuration和@EnableAutoConfiguration ...
- SpringBoot注解大全(转)
原文链接:[springBoot系列]--springBoot注解大全 一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Co ...
- SpringBoot注解验证参数
SpringBoot注解验证参数 废话不多说,直接上表格说明: 注解 作用类型 解释 @NotNull 任何类型 属性不能为null @NotEmpty 集合 集合不能为null,且size大于0 @ ...
随机推荐
- c#自带压缩类实现的多文件压缩和解压
用c#自带的System.IO.Compression命名空间下的压缩类实现的多文件压缩和解压功能,缺点是多文件压缩包的解压只能调用自身的解压方法,和现有的压缩软件不兼容.下面的代码没有把多文件的目录 ...
- Android 开发替换Launcher
做android产品的时候,根据需求会制定各种各样的Launcher,因此,在此记录替换系统Launcher的流程. 1.修改frameworks/base/core/java/android/con ...
- 140. 单词拆分 II
Q: 给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,在字符串中增加空格来构建一个句子,使得句子中所有的单词都在词典中.返回所有这些可能的句子. 说明: 分隔时可以重复使用字典 ...
- Harmonic Number (II) 数学找规律
I was trying to solve problem '1234 - Harmonic Number', I wrote the following code long long H( int ...
- jvm(2):垃圾收集和内存分配
typora-root-url: ./ 垃圾收集 垃圾收集器关注的是线程共享的这部分内存. jvisualvm用来监控JVM的运行情况,可以用它来查看和浏览Heap Dump.Thread Dump. ...
- 三种方法获取 lua时间戳
ngx.now() 返回:1523174287.735 毫秒级精度的时间戳(获取的是nginx缓存的时间戳,并非实时刷新, 如果希望刷新,可以在获取前一行加上 ngx.update_tim ...
- mybatis 查询list,内容为null,但list的size 为1
List<Integer> cityList = resourcePartnerService.selectCityList(userId); 需要在SQL里where语句加上 字段不为n ...
- 题解【POJ3252】Round Numbers
Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, P ...
- 使用 navigator.sendBeacon() 上报数据
http://kaifage.com/notes/76/navigator-sendBeacon.html 如某些统计系统,在页面unload时,如果要上报当前数据,采用xhr的同步上报方式,会阻塞当 ...
- linux系统下如何打开端口
1)vi /etc/sysconfig/iptables 2)-A INPUT -m state --state NEW -m tcp -p tcp --dport xxxxxxxxxx -j ACC ...