依賴:
<!-- 配置綁定--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency>
yml中添加參數配置,注意值前加個空格,不然不試別。
user:
name: wanli
代碼:
@Value("${user.name}") private String name;