application.yml
- server:
- port: 8080
-
-
- #logging:
- # level:
- # root: info(默认)
-
- array:
- name: zzl
- age: 18
- subject:
- - Java
- - Vue
- - SpringBoot
@Value注解的使用:从yml配置文件中获取数据,即可在类中使用
- @Value("${server.port}")
- private String port;
-
- @Value("${array.subject[0]}")
- private String subject_00;
@Autowired 装配配置信息的对象,把数据打包进一个对象中,再放进容器中给别人注入
- package com.example.springboot_learn;
-
- import lombok.Data;
- import org.springframework.boot.context.properties.ConfigurationProperties;
- import org.springframework.stereotype.Component;
-
- @Data
- @Component
- @ConfigurationProperties(prefix = "array")
- public class ApplicationData {
- private String name;
- private Integer age;
- private String[] subject;
- }
- @Autowired
- private ApplicationData applicationData;
多环境开发配置

打包成jar包后,测试人员可以根据自己的需要进行身份转换和参数临时变换
