第一次是用这个IDE,根据提示导了一个依赖,但是结果打印出来是null,也没有报错,求老师指导!
是这个依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency>
然后,打印结果截图:
Hello! SpringBoot ! nullnull
这个是源代码:
@Component
@ConfigurationProperties(prefix = "girl")
public class GirlProperties {
private String cupSize;
private Integer age;
以下是get、set方法
然后还有控制类的代码:
@RestController
public class helloController {
@Autowired
private GirlProperties girlProperties;
@RequestMapping(value = "/hello",method = RequestMethod.GET )
public String say(){
return "Hello! SpringBoot ! "+girlProperties.getCupSize()+girlProperties.getAge();
}