第一次是用這個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();
? ?}
2017-08-15
同樣null
2017-06-06
看一下配置文件和類中對應的字段一定要保持一致,
2017-04-30
我的也是null 找不到原因
2017-03-25
看一下配置文件屬性名稱和定義的類的字段名稱是否一致