【SpringBoot 框架】- SpringBoot 配置文件

【SpringBoot 框架】- 入门——环境搭建、工程热部署、idea快捷创建SpringBoot项目

【SpringBoot 框架】- SpringBoot 原理分析

【SpringBoot 框架】- SpringBoot 配置文件

【SpringBoot 框架】- SpringBoot 整合 Mybatis、Junit、Redis

目录

一、SpringBoot配置文件类型

1. application.properties 配置文件

2. application.yml(application.yaml) 配置文件

二、配置文件与配置类的属性映射

1、使用注解 @Value 映射

2、使用注解 @ConfigurationProperties 映射


一、SpringBoot配置文件类型

==================

SpringBoot是基于约定的,所以很多配置都有默认值,但如果想使用自己的配置替换默认配置的话 ,就可以自己编写配置文件进行相应配置,在我的上一篇博文SpringBoot原理分析(https://blog.csdn.net/One_L_Star/article/details/103056583)中,起步依赖spring-boot-starter-parent 中,有配置文件的引入,如下:

true

${basedir}/src/main/resources

**/application*.yml

**/application*.yaml

**/application*.properties

可以看到,${basedir}/src/main/resources 表示资源的加载文件,资源文件包括下面三种格式的,也就是说,咱们在配置SpringBoot资源文件的时候都是以 application*.yml、application*.yaml、application*.properties文件格式,.yml 和 .yaml 文件相同,而且在配置的时候一般都以 application 命名,所以SpringBoot配置文件可以归为以下两种:

  • application.proper

你可能感兴趣的:(程序员,spring,boot,java,spring)