@ConfigurationProperties注解和@PropertySource注解为属性批量赋值

@ConfigurationProperties注解

步骤1:往pom.xml文件中添加依赖

<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-configuration-processor</artifactId>
			<optional>true</optional>
		</dependency>

步骤2:

@ConfigurationProperties注解和@PropertySource注解为属性批量赋值_第1张图片

步骤3:

@ConfigurationProperties注解和@PropertySource注解为属性批量赋值_第2张图片

步骤4:浏览器访问

@ConfigurationProperties注解和@PropertySource注解为属性批量赋值_第3张图片

@PropertySource注解

步骤1:在resources目录下创建以下目录和文件

@ConfigurationProperties注解和@PropertySource注解为属性批量赋值_第4张图片

步骤2:

@ConfigurationProperties注解和@PropertySource注解为属性批量赋值_第5张图片

步骤3:控制层

步骤4: .yml环境配置

@ConfigurationProperties注解和@PropertySource注解为属性批量赋值_第6张图片

步骤5:

@ConfigurationProperties注解和@PropertySource注解为属性批量赋值_第7张图片

你可能感兴趣的:(springboot)