Spirngboot basic review

1. Convention is better than configuration

Build Anything with Spring Boot:Spring Boot is the starting point for building all Spring-based applications. Spring Boot is designed to get you up and running as quickly as possible, with minimal upfront configuration of Spring.

The above is a quote from the official website, which roughly says: Spring Boot is the starting point for all Spring-based projects. Spring Boot is designed to let you run Spring applications as quickly as possible and minimize your configuration files.
This sentence should be the reason for the birth of springBoot.

Convention over Configuration (Convention over Configuration), also known as programming by convention, is a software design paradigm.

Essentially, the system, class library, or framework should assume reasonable default values ​​instead of requiring unnecessary configuration. For example, if there is a class named User in the model, the corresponding table in the database will be named user by default. Only when deviating from this convention, for example, if you want to name the table person, you need to write the configuration about this name.

For example, architects usually set up projects to restrict software development from writing code casually, and formulate a set of specifications to allow developers to develop coding tests according to unified requirements, which enhances development efficiency and review code efficiency. So when you write code, you need to name it according to the requirements, so that the unified code has good readability and maintainability.

Conventions are better than configuration. Simple understanding is to follow the conventions.

Two, SpirngBoot concept

2.1 Analysis of the advantages and disadvantages of Spring

  • advantage

Spring is a lightweight alternative to Java Enterprise Edition (Java Enterprise Edition, JEE, also known as J2EE). Without developing heavyweight
Enterprise JavaBean (EJB), Spring provides a relatively simple method for enterprise Java development, dependency injection and by plane
to the programming section, with a simple Java objects (Plain Old Java Object, POJO) implements EJB function

  • Disadvantage

Although Spring's component code is lightweight, its configuration is heavyweight. In the beginning, Spring used XML configuration, and it was a
lot of XML configuration. Spring 2.5 introduces annotation-based component scanning, which eliminates a lot of explicit XML
configuration for the application's own components . Spring 3.0 introduces Java-based configuration, which is a type-safe and reconfigurable configuration method that can replace XML.
All these configurations represent losses during development. Because there is a need to
switch thinking between thinking about Spring feature configuration and solving business problems , writing configuration squeezes time for writing application logic. Like all frameworks, Spring is practical, but at the same time it requires
a lot of rewards.
In addition, the dependency management of the project is also a time-consuming and labor-intensive thing. When setting up the environment, you need to analyze the coordinates of which libraries to import,
and you also need to analyze the coordinates of other libraries that are dependent on it. Once you choose the wrong version of the dependency, the ensuing incompatibility
will be seriously hindered. Project development progress

2.2 Springboot solves the above spring problems

SpringBoot's improvement and optimization of the above-mentioned shortcomings of Spring are based on the idea that conventions are better than configuration, so that developers do not have to switch their thinking between configuration and logical business, and devote themselves to the coding of logical business, thus Greatly improve the efficiency of development and shorten the project cycle to a certain extent.

  • Start-up dependence

The initial dependency is essentially a Maven project object model (Project Object Model, POM), which defines the transitive dependency on other libraries.
Together, these things support a certain function.
Simply put, the initial dependency is to pack the coordinates with a certain function together and provide some default functions.

  • Automatic configuration

The automatic configuration of springboot refers to springboot, which will automatically register some configuration beans into the ioc container. We can use annotations such as @autowired or @resource where necessary.
The form of "automatic" is that we only need to introduce the packages we want to use. We don't care about the related configuration at all. Springboot will automatically inject these configuration beans. We can directly use these beans to
springboot: simple, fast and convenient to build Project; configuration-free integration of mainstream development frameworks; greatly improved development and deployment efficiency

2.3 springboot environment construction

Insert picture description here

1.5 Review of Springboot unit testing and hot deployment

Insert picture description here

Hot deployment

Insert picture description here
Insert picture description here
Insert picture description here

1.6 Review of properties of Springboot configuration file

1.7 Review of yaml of Springboot configuration file

1.8 Review of Springboot configuration file injection types

1.9 Springboot custom configuration files and classes

1.10 Springboot random number setting and parameter reference

Guess you like

Origin blog.csdn.net/qq_42082278/article/details/111509806