- 博客(2)
- 收藏
- 关注
原创 SpringBoot 注入properties资源文件的值(二)
(1) 利用@Value("${}") 的注入方式在数量多的时候也是个麻烦。 如果注入的数据是一类,或者说是一个对象,还有更简便的方式。 1、在application.properties文件中写入 book.name= springboot book.author=wangyi book.price=25 2、自定义bean如下 @Component @ConfigurationProperties(prefix="bo...
2021-09-05 22:15:51
338
原创 SpringBoot 注入properties资源文件的值(一)
在常规的spring环境当中,注入properties文件里的值,是通过@PropertySource 指明properties文件的位置,然后利用@Value注入值。 例如: aa.properties test=this is test java @PropertySource("classpath:aa.properties") public class Atest{ ...
2021-09-05 18:19:56
742
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人