解决自定义配置文件无提示
application系列的配置文件都有提示,但自定义yml、properties等文件无提示,原因是没有在IDE中,将它们加入到配置文件列表中!
@ImportSource和@PropertySource区别?
- @PropertySource 用于引入 *.Properties 或者 *.yml ,用于给javabean注入值
- @ImportResource用于引入 *.xml类型的配置文件在SpringBoot中已经被配置类替代
@PropertyeSource一般用在javabean的类名上
- @ImportResource一般用于启动类上
配置文件站位符
- RandomValuePropertySource:配置文件中可以使用随机数
${random.value}
${random.int}
${randm.int(10)}
- 属性配置站位符
person.lastName=杰瑞${random.uuid}
person.age=12
person.alive=true
person.birth=2020/02/20
person.maps.k1=value1
person.maps.k2=value2
person.lists=a,b,c
# 对于没有从未定义过的值,可以用 : 指定默认值
person.dog.name=${person.sayhello:Greeting~!}`s dog
person.dog.age=${person.age}