Summary of Self-study Springboot Basics
1. What is SpringBoot?
SpringBoot provides a quick way to use Spring. Based on the idea that convention is better than configuration, developers do not have to switch between configuration and logic business, and devote themselves to the code writing of logic business, thus greatly Improve the efficiency of development and shorten the project cycle to a certain extent
1. The disadvantages of spring
(1) cumbersome configuration
(2) cumbersome dependencies
2. Spring Boot function
(1) Automatic configuration
(2) Startup dependency: dependency transfer
(3) Accessibility
Spring Boot is not an enhancement to Spring, but a way to quickly use Spring
Two, SpringBoot configuration
⚫ SpringBoot provides 2 types of configuration files: propertyis and yml/yaml
⚫ Default configuration file name: application
⚫ The priority in the same directory is: properties > yml > yaml
1、yaml
The full name of YAML is YAML Ain't Markup Language. YAML is an intuitive data serialization format that can be recognized by computers, and is easy to be read by humans, easy to interact with scripting languages, and can be supported by different programming of YAML libraries Language program import, such as: C/C++, Ruby, Python, Java, Perl, C#, PHP, etc. YML files are data-centric and more concise than the traditional xml format. The extension of the YAML file can use .yml or .yaml
2、profile
When we develop Spring Boot applications, usually the same set of programs will be installed in different environments, such as: development, testing, production, etc. Among them, the database address, server port and other configurations are different. If you have to modify the configuration file every time you pack it, it will be very troublesome. The profile function is for dynamic configuration switching
3. Internal configuration loading order
3. Spring Boot integrates other frameworks
1. SpringBoot integrates Junit
① Build a SpringBoot project
② Introduce starter-test starting dependencies
③ Write test classes
④ Add test-related comments
• @RunWith(SpringRunner.class)
• @SpringBootTest(classes = startup class.class)
⑤ Write test methods
2. SpringBoot integrates Redis
① Build SpringBoot project
② Introduce redis start-up dependencies
③ Configure redis related properties
④ Inject RedisTemplate template
⑤ Write test methods and test
3. SpringBoot integrates MyBatis
① Build SpringBoot project
② Introduce mybatis start-up dependencies, add mysql driver
③ Write DataSource and MyBatis related configuration
④ Define tables and entity classes
⑤ Write dao and mapper files/pure annotation development
⑥ Test