Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Methods of SpringBoot dependent management and automatic assembly

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces SpringBoot dependency management and automatic assembly methods related knowledge, detailed and easy to understand, simple and fast operation, with a certain reference value, I believe that everyone will have a harvest after reading this SpringBoot dependency management and automatic assembly method article, let's take a look at it.

1.1 Dependency Management Parent Project Dependency Management

Automatic version arbitration: The dependent version is specified in the parent project. It only needs to be imported, and there is no need to write the version number.

dependency management org.springframework.boot spring-boot-starter-parent 2.3.4. RELEASE his parent project org.springframework.boot spring-boot-dependencies 2.3.4. RELEASE almost declares the version number of all commonly used dependencies in development, automatic version arbitration mechanism development import Staeter scenario starter 1, see a lot of spring-boot-starter-*: * for a certain scenario 2, as long as the starter is introduced, all the commonly needed dependencies of this scenario are automatically introduced 3, SpringBoot All supported scenarios https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-starter4, see *-spring-boot-starter: A third-party scenario launcher for simplified development. 5. The lowest dependency of all scene starters org.springframework.boot spring-boot-starter 2.3.4.RELEASE compile pays attention to the version number out of order, automatic version arbitration

1. Since its introduction, it has not been possible to write a version by default.

2. To introduce jar without version arbitration, you need to write version number

For example:

Version 8.0 of mtsql specified in parent project in SpringBoot2

We want to declare version numbers when we need to use lower versions

Steps:

1. Check spring-boot-dependencies for the key used to specify the version you are currently dependent on.

2. Overwrite configuration in current project

5.1.43 1.2 automatic assembly

Auto-match Tomcat

Introducing Tmocat dependency

Configure Tmocat

org.springframework.boot spring-boot-starter-tomcat 2.3.4.RELEASE compile

Automatic configuration of common Web features, such as: character code problems

SpringBoot helps users configure common scenarios for desired web development

Default package structure

Components in the main package and all subpackages below are scanned by default

There is no need to scan configuration packages in configuration files as before

If you want to change the scan path, use @SpringBootApplication (scanBasePackages="scan path") or

@ComponentScan Specify scan path under main program

@SpringBootApplication is equivalent to @SpringBootConfiguration@EnableAutoConfiguration@ComponentScan("com.atguigu.boot")

For example:

Package structure:

For WorldController to work, you need to reset the package scan, or put this package under the main package or its subpackages

(Red line is designated package scan)

Various configurations have default configurations

Default configuration is ultimately mapped to a class, such as: MultipartProperties

The configuration file values are eventually bound to each class that creates objects in the container IOC

Load all autoconfiguration items on demand

A lot of starters.

What scenes need to be introduced to enable automatic assembly if you want automatic assembly to be effective

All of SpringBoot's autoconfiguration features are in the Spring-boot-autofigure package.

About "SpringBoot dependency management and automatic assembly method" this article content introduced here, thank you for reading! I believe everyone has a certain understanding of the knowledge of "SpringBoot dependency management and automatic assembly methods." If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report