In the Spring Boot entry program, the project pom.xml file has two core dependencies, namely spring-boot-starterparent and spring-boot-starter-web. The relevant introduction to these two dependencies is as follows:
1. spring-boot-starter-parent dependency
Find the spring-boot-starter-parent dependency in the pom.xml file in the chapter01 project. The sample code is as follows:
<!-- Spring Boot父项目依赖管理 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent<11./artifactId> <version>2.2.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
In the above code, The spring-boot-starter-parent dependency serves as the unified parent project dependency management of the Spring Boot project, and unifies the project version number to 2.2.2.RELEASE. This version number can be modified according to actual development needs.
Use "Ctrl left mouse button" to enter and view the underlying source file of spring-boot-starter-parent. It is found that the underlying source file of spring-bootstarter-parent has a parent dependency spring-boot-dependencies. The core code is as follows
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.2.2.RELEASE</version> <relativePath>../../spring-boot-dependencies</relativePath> </parent>
Continue to view the underlying source files of spring-boot-dependencies. The core code is as follows:
<properties> <activemq.version>5.15.11</activemq.version> ... <solr.version>8.2.0</solr.version> <mysql.version>8.0.18</mysql.version> <kafka.version>2.3.1</kafka.version> <spring-amqp.version>2.2.2.RELEASE</spring-amqp.version> <spring-restdocs.version>2.0.4.RELEASE</spring-restdocs.version> <spring-retry.version>1.2.4.RELEASE</spring-retry.version> <spring-security.version>5.2.1.RELEASE</spring-security.version> <spring-session-bom.version>Corn-RELEASE</spring-session-bom.version> <spring-ws.version>3.0.8.RELEASE</spring-ws.version> <sqlite-jdbc.version>3.28.0</sqlite-jdbc.version> <sun-mail.version>${jakarta-mail.version}</sun-mail.version> <tomcat.version>9.0.29</tomcat.version> <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version> <thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-dataattribute.version> ... </properties>
As can be seen from the underlying source files of spring-boot-dependencies, this file uses tags to support some common technologies. The dependency files of the framework have unified version number management, such as activemq, spring, tomcat, etc., all have versions that match the Spring Boot 2.2.2 version. This is why pom.xml does not need to mark the dependency file version number when introducing dependency files. .
It should be noted that if the dependency file introduced by pom.xml is not managed by spring-boot-starter-parent, then when pom.xml introduces the dependency file, you need to use a label to specify the version number of the dependency file.
Question 2: The main function of the spring-boot-starter-parent parent dependency starter is to perform unified version management. So where does the JAR package that the project line depends on come from?
2. spring-boot-starter-web dependency
View spring-boot-starter-web dependency file source code, the core code is as follows
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>2.7.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-json</artifactId> <version>2.7.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <version>2.7.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.3.21</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.3.21</version> <scope>compile</scope> </dependency> </dependencies>
It can be found from the above code that spring-boot-starter-web The main function of the dependency launcher is to provide all the underlying dependencies required for web development scenarios.
Just like this, when the spring-boot-starter-web dependency starter is introduced in pom.xml, Web scenario development can be realized without the need to additionally import the Tomcat server and other Web dependency files. Of course, the version numbers of these imported dependency files are uniformly managed by the spring-boot-starter-parent parent dependency.
In addition to the Web dependency starter introduced above, Spring Boot also provides related dependencies for many other development scenarios. We can open the official Spring Boot documentation and search for the "Starters" keyword to query the scenario dependency starter.
Lists some of the scenario dependency starters officially provided by Spring Boot. These dependency starters are suitable for different scenario development and only need to be used in the pox.xml file. Just import the corresponding dependency starter.
It should be noted that Spring Boot official does not provide scenario launchers for all technical frameworks developed in scenarios, such as the database operation framework MyBatis, Alibaba's Druid data source, etc. Spring Boot official does not provide them. The corresponding dependency starter. In order to make full use of the advantages of the Spring Boot framework, when Spring Boot officially did not integrate these technical frameworks, the development teams of technical frameworks such as MyBatis and Druid took the initiative to integrate with the Spring Boot framework and implement their respective dependency starters, such as mybatis-spring-boot-starter, druid-spring-boot-starter, etc. When we introduce these third-party dependency starters in the pom.xml file, remember to configure the corresponding version number.
The above is the detailed content of SpringBoot dependency management configuration method. For more information, please follow other related articles on the PHP Chinese website!

Javaremainsagoodlanguageduetoitscontinuousevolutionandrobustecosystem.1)Lambdaexpressionsenhancecodereadabilityandenablefunctionalprogramming.2)Streamsallowforefficientdataprocessing,particularlywithlargedatasets.3)ThemodularsystemintroducedinJava9im

Javaisgreatduetoitsplatformindependence,robustOOPsupport,extensivelibraries,andstrongcommunity.1)PlatformindependenceviaJVMallowscodetorunonvariousplatforms.2)OOPfeatureslikeencapsulation,inheritance,andpolymorphismenablemodularandscalablecode.3)Rich

The five major features of Java are polymorphism, Lambda expressions, StreamsAPI, generics and exception handling. 1. Polymorphism allows objects of different classes to be used as objects of common base classes. 2. Lambda expressions make the code more concise, especially suitable for handling collections and streams. 3.StreamsAPI efficiently processes large data sets and supports declarative operations. 4. Generics provide type safety and reusability, and type errors are caught during compilation. 5. Exception handling helps handle errors elegantly and write reliable software.

Java'stopfeaturessignificantlyenhanceitsperformanceandscalability.1)Object-orientedprincipleslikepolymorphismenableflexibleandscalablecode.2)Garbagecollectionautomatesmemorymanagementbutcancauselatencyissues.3)TheJITcompilerboostsexecutionspeedafteri

The core components of the JVM include ClassLoader, RuntimeDataArea and ExecutionEngine. 1) ClassLoader is responsible for loading, linking and initializing classes and interfaces. 2) RuntimeDataArea contains MethodArea, Heap, Stack, PCRegister and NativeMethodStacks. 3) ExecutionEngine is composed of Interpreter, JITCompiler and GarbageCollector, responsible for the execution and optimization of bytecode.

Java'ssafetyandsecurityarebolsteredby:1)strongtyping,whichpreventstype-relatederrors;2)automaticmemorymanagementviagarbagecollection,reducingmemory-relatedvulnerabilities;3)sandboxing,isolatingcodefromthesystem;and4)robustexceptionhandling,ensuringgr

Javaoffersseveralkeyfeaturesthatenhancecodingskills:1)Object-orientedprogrammingallowsmodelingreal-worldentities,exemplifiedbypolymorphism.2)Exceptionhandlingprovidesrobusterrormanagement.3)Lambdaexpressionssimplifyoperations,improvingcodereadability

TheJVMisacrucialcomponentthatrunsJavacodebytranslatingitintomachine-specificinstructions,impactingperformance,security,andportability.1)TheClassLoaderloads,links,andinitializesclasses.2)TheExecutionEngineexecutesbytecodeintomachineinstructions.3)Memo


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
