Error creating bean with name ‘helloController‘: Injection of autowired dependencies failed;

Error content:
when using the automatic injection of springboot, the configuration file in yaml format is used for injection, but the error is always reported and cannot be injected.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘helloController’: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder ‘name’ in value “${name}”

I searched many posts saying that I should pay attention to the application scanning my folder and corresponding subfolders. Many people step on the pit in this place, but my problem is not here
code

@RestController
public class HelloController {

    @Value(value = "${name}")
    private String name;
    
    @RequestMapping("/hello")
    public String hello(){
        System.out.println(name);
        return "hello Spring Boot !";
    }
}

Add the annotation to read the configuration file on hellocontroller

@PropertySource(value = "classpath:application.yaml")

That solved the problem

Read More: