一:spring-boot,强大的依赖管理整合功能,根据习惯优于配置约定,进行去配置化(spring全家桶套件,javaee中涉及的技术)
@SpringBootApplication的三大注解意义
1.@spring
@SpringBootConfigruation包含@Configruation
1)该类是一个配置类
2)该类交给了springIOC管理相当于springMVC中的@Component
2.@EnableAutoConfigruation
1)自己写的包@AutoConfigurationPackage 将项目包及其子包自动配置进ComponentScan中相当于<context:component-scanbase-package="cn.itcast" />
2)第三方依赖@Import({AutoConfigurationImportSelector.class})将第三方的依赖(配置,jar包)自动管理配置spring-boot-autoconfig/META-INF/spring.factories中的三方依赖
3)利用@ConditionOnXxx满足条件决定不同的项目是否启用相关依赖,并且可以在application.properties中进行依赖包的相关配置,这里的配置包来源于依赖包的"prefix"
4)在application.properties中配置debug=true可以看到项目开启了哪些依赖(Positive),没有开启哪些依赖(Negative)
3.@ComponentScan
二:yaml文件的格式与两种写法
1 public class Student { 2 private String name; 3 private String subject[]; 4 private List<String> skill; 5 private Pet pet; 6 private Map<String,String> location; 7 8 public String getName() { 9 return name; 10 } 11 12 public void setName(String name) { 13 this.name = name; 14 } 15 16 public String[] getSubject() { 17 return subject; 18 } 19 20 public void setSubject(String[] subject) { 21 this.subject = subject; 22 } 23 24 public List<String> getSkill() { 25 return skill; 26 } 27 28 public void setSkill(List<String> skill) { 29 this.skill = skill; 30 } 31 32 public Pet getPet() { 33 return pet; 34 } 35 36 public void setPet(Pet pet) { 37 this.pet = pet; 38 } 39 40 public Map<String, String> getLocation() { 41 return location; 42 } 43 44 public void setLocation(Map<String, String> location) { 45 this.location = location; 46 } 47 48 }
student: name: jack birth: 1993/11/02 subject: -数学 -语文 skill: -java -c# pet: name: wc style: hsq location: city: 济南 zone: 市中
student subject: ["数学",语文] skill: [java,‘c#‘] pet: {name: wc,style: hsq} location: {city: 济南,zone: 市中}
原文:https://www.cnblogs.com/-zgt/p/13677922.html