springboot中写properties文件,为什么两个bean中不能同时用@Value取值

第一个bean:
@RestController
public class HelloController {
@Value("${person.last-name}")
private String name;

@RequestMapping("sayhello")
public String sayHello(){
    return "hello" + name;
}

}

第二个bean:
@Component
//@Validated
//@ConfigurationProperties(prefix = "person")
public class Person {
    @Value("${last-name}")
    private String lastName;
    private Integer age;
    private Boolean boss;
    private Date birth;

get、set方法啥的就不复制了。有没有大佬知道这是怎么回事鸭

https://blog.csdn.net/dkbnull/article/details/81953190

@ConfigurationProperties,声明后,不需要在类中的属性上声明@Value("${last-name}")

实体类里面你可以保持原生的,正常 @Value("${....}")我们都是和yml文件中映射读取配置文件地址,
然后再controller里面配置@Value("${....}")例如下面
class XXXController{

@Value("${xx-xxx}")
private String A;

    @RequestMapping(value="/xx",method=xxx)
    public xxx xxx(xx,xx){

逻辑传参调用A;

}
}