1,@Value

直接在定义的属性上面使用注解 @Value("属性值")


2,propertie配置文件

配置文件key=value
在类上面使用注解@PropertySource("classpath:")
在属性的上面使用注解@Value("${属性名}")


3,yaml配置文件

dog:
  name: liming
  age: 22

@ConfigurationProperties(prefix="")