SpringBoot: related system requirements, HelloWord, dependency management, automatic configuration (shallow)---- 2

Keywords: Java Spring Boot Back-end

system requirements

The differences between different versions of ssdss can be seen as follows:

ssdss1, look for the corresponding version, such as the latest version is 2.5.6, so we have to look at the requirements of the corresponding version.

ssdss2, click "Getting Started" to view related system requirements
ssdss 3. We found that the system requires Maven to be at least version 3.5 and jdk8 to be compatible with jdk17.
ssdssMaven configuration: (configure settings.xml under config in maven's file)

       <name>Nexus aliyun</name>


ssdss requirements: browse send/hello requests, respond to Hello, World!.

The official documents are: https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started.html#getting-started.first-application

Create Maven Project

Introducing dependencies in pom files



Create Main Program

Write Logical Business


ssdss runs the main program with the following results:

We can see that Tomcat has run browser-side access on port 8080: http://localhost:8080/hello

Official address: https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started.html#getting-started.first-application.pom

Simplified configuration

Simplified configuration


ssdss executes maven's package command to jar the project directly to the target server. cmd executes packaged programs: (if tomcat is used, pack specifically into a war package)

java -jar boot-01-helloworld-1.0-SNAPSHOT.jar

ssdss: Sometimes the cmd command does not start the springboot project, probably because Quick Edit Mode is turned on in the properties. Cancel method: Right-click the title area above the window of the cmd console to open Options to uncheck Quick Edit Mode

Explanation of Automatic Configuration

Dependency Management

ssdss @ Parent project doing dependency management

   <parent>   Dependency Management
    Parent project above
  Almost all version numbers of dependencies commonly used in development are declared==>Automatic Version Arbitration Mechanism

ssdss # Develop Import starter Scene Launcher


ssdss1. See many spring-boot-starter-*:* referring to a scene.
ssdss2.As soon as starter is introduced, all the dependencies of the general needs of this scenario are automatically introduced.
ssdss3. SpringBoot All Supported Scenarios
ssdss4.See *-spring-boot-starter: Scene launcher for simplified development provided by third parties.
ssdss5.The bottom-most dependency of all scene launchers.
ssdss6.You can also create your own starter.

No need to care about version number, automatic version arbitration

ssdss1. Importing dependency defaults allows you to write no versions

ssdss2.Introduce jar for non-version arbitration, write version number.

Default version number can be modified

ssdss1. View the key in spring-boot-dependencies that specifies the version currently dependent on.

ssdss2. Rewrite key's configuration in the current project - Proximity first principle

1,See spring-boot-dependencies Which specifies the version currently dependent on key.  
2,Rewrite in Current Project key Configuration 

View Auto-Configured Components

ssdss looks at which components are configured in the main program class:

* Main Program Class 
* @SpringBootApplication:On the main program, this is a SpringBoot application 
public class MainApplication { 
	public static void main(String[] args) { 
		// View Auto-Configured Components 
		// 1. Return to IoC container 
		ConfigurableApplicationContext run = SpringApplication.run(MainApplication.class, args); 
		// 2. View the components inside the container 
		String[] names = run.getBeanDefinitionNames(); 
		for (String name:names ) { 

View Auto-Configured Components

ssdss automatically pairs Tomcat: Introduce Tomcat dependency. Configure Tomcat


ssdss Automatically Matches SpringMVC

sdssdss * Introduce Spring MVC Full Set of Components

ssddsss * Automatically pair Spring MVC common components (features)

ssdss automatically matches common web features such as character encoding issues SpringBoot helps us configure common scenarios for all web development

ssdss changes the scan path: @SpringBootApplication(scanBasePackages="com.atguigu") or @ComponentScan specifies the scan path

@SpringBootApplication = @SpringBootConfiguration ā˛•@EnableAutoConfigurationā˛• @ComponentScan("com.atguigu.boot")

ssdss has default values for various configurations

sdssdssssdss * Default configurations are ultimately mapped to MulyipartProperties

The value of the sdsssdss * configuration file is eventually bound to each class, which creates objects in the container

ssdss loads all automatic configurations on demand

Sdsssssdss * Very many starter s

Sdsssssdss * Introduce those scenes so that the automatic configuration of this scene is turned on

Sdsssssdss @ SpringBoot All autoconfigurations are in the spring-boot-autoconfigure package

Posted by visonardo on Sun, 31 Oct 2021 13:58:07 -0700