标签:value bsp pat student 读取配置 path 配置 ati style
1.注入 基本字符
public class Student {
@Value("qq")
private String name;
@Value("12")
private Integer age;
2.el表达式
public class Student {
@Value("qq")
private String name;
@Value("#{20-2}")
private Integer age;
3.读取配置文件
配置文件
student.name=Martin
配置类
@Configuration @PropertySource(value = "classpath:/app.properties") public class Config { @Bean public Student student(){ return new Student(); } }
Bean类
public class Student{ @Value("${student.name}") private String name; private Integer age;
标签:value bsp pat student 读取配置 path 配置 ati style
原文地址:https://www.cnblogs.com/qin1993/p/11731377.html