三十六 Java开发学习----SpringBoot三种配置文件解析( 四 )

BookController 内容如下:
@RestController@RequestMapping("/books")public class BookController {        @Autowired    private Enterprise enterprise;?    @GetMapping("/{id}")    public String getById(@PathVariable Integer id){        System.out.println(enterprise.getName());        System.out.println(enterprise.getAge());        System.out.println(enterprise.getSubject());        System.out.println(enterprise.getTel());        System.out.println(enterprise.getSubject()[0]);        return "hello , spring boot!";  }}注意:使用第三种方式,在实体类上有如下警告提示

三十六 Java开发学习----SpringBoot三种配置文件解析

文章插图
这个警告提示解决是在 pom.xml 中添加如下依赖即可
<dependency>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-configuration-processor</artifactId>    <optional>true</optional></dependency>【三十六 Java开发学习----SpringBoot三种配置文件解析】

经验总结扩展阅读