springboot xml配置,properties配置,profile配置
2017-01-13 00:00
531 查看
摘要: springboot xml配置,properties配置
例:@InportResource({"classpath:some-XXXXX.xml","classpath:another-XXXXX.xml"})
使用注解@Value{}
例:
aaa.propeties
book.name=zhangsan
book.price=50
@Component
@ConfigurationProperties(prefix="book",location={"classpath:aaa.properties"})
public class Book(){
private String name;
private String price;
setter getter....
}
1.使用xml配置
@InportResource加载xml例:@InportResource({"classpath:some-XXXXX.xml","classpath:another-XXXXX.xml"})
2.常规属性配置
application.properties 中添加的属性使用注解@Value{}
3.类型安全的配置(基于properties)
通过@ConfigurationProperties讲properties和bean进行关联。例:
aaa.propeties
book.name=zhangsan
book.price=50
@Component
@ConfigurationProperties(prefix="book",location={"classpath:aaa.properties"})
public class Book(){
private String name;
private String price;
setter getter....
}
4.profile配置
profile是spring用来针对不同环境对不同配置进行的支持,全局profile使用application-{profile}.properties,在application.properties中设置spring.profile.active=XXX来制定profile。相关文章推荐
- SpringBoot内部配置:“application.properties配置”和”使用XML配置”,读取属性文件中的内容,日志配置,Profile配置(学习:SpringBoot实战)
- Spring boot pom.xml和application.properties配置信息
- Spring boot pom.xml和application.properties配置信息
- Spring入门Blog[十、Spring DBCP用xml和properties2种格式配置DataSource]
- spring boot application properties配置详解
- 31. Spring Boot导入XML配置【从零开始学Spring Boot】
- spring-boot properties 配置信息
- spring boot application.properties 配置
- Spring学习笔记 在XML配置文件中使用properties文件的键值
- spring boot 使用application.properties 进行外部配置
- (转)Spring boot——logback.xml 配置详解(二)
- spring-boot application.properties配置文件和自定义配置文件
- spring boot application.properties文件外部配置
- Spring入门Blog[十、Spring用xml和properties方式配置数据源]
- (转)Spring boot——logback.xml 配置详解(三)<appender>
- spring读取properties和xml配置文件的方法
- spring boot application properties配置详解
- SpringBoot 配置文件 application.properties(二)
- 【springboot】Spring boot配置文件 application.properties
- Spring Boot与FreeMarker集成后配置全局模板转义html/xml