English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

إدارة الاعتماديات في SpringBoot

يدير Spring Boot التبعية والتعديلات بشكل تلقائي. يقدم كل إصدار من Spring Boot قائمة بالتبعيات التي يدعمها. يمكن مقارنة قائمة التبعيات مع Maven التي تستخدم معًا قائمة الموادجزء من (إعداد بداية الربيع). لذلك، لا نحتاج إلى تحديد إصدار التبعية في الإعدادات. يدير Spring Boot التبعية بنفسه. عند تحديث إصدار Spring Boot، يقوم Spring Boot بتحديث جميع التبعيات بشكل تلقائي وبطريقة متسقة.

فوائد إدارة التبعيات

يقدم معلومات التبعية بشكل مركزي عن طريق تحديد إصدار Spring Boot في مكان واحد. يساعدها في التبديل بين الإصدارات المختلفة. يمنع عدم التطابق بين مكتبات Spring Boot المختلفة. نحن بحاجة فقط إلى كتابة اسم المكتبة وتحديد الإصدار. هذا مفيد جدًا في مشاريع متعددة المكونات.

Note: إذا لزم الأمر، يمكن أن تغطي Spring Boot إصدار الاعتمادات.

نظام إدارة الاعتماد Maven

مشروع Maven من يورث spring-boot-starter-parent الميزات التالية:

الافتراضي إصدار محول Java UTF-8 مصدر الت编码 يورث من spring-boot-dependency-pom Dependency Section Dependency Section  tag. It manages the versions of common dependencies. For this dependency, it will ignore dependencies inherited from spring-boot-dependencies POM intelligentresource filtering intelligentplugin configuration

Inherit Starter Parent

When configuring the project, the following spring-boot-starter-parent will be automatically inherited.

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.BUILD-SNAPSHOT</version> <!-- lookup parent from repository -->
<relativePath/> 
</parent>
Note: In the above dependencies, we only specify the Spring Boot version. If you want to add other starters, just deletetag. Similarly, we can also override personal dependencies by overriding properties in the project.

For example, if you want to add another dependency with the same artifact as the injected one, inject the dependency again <properties>tag to override

Change Java version

We can also use <java.version>Use the tag to change the Java version.

<properties>  
<java.version>1.8</java.version>  
</properties>

Add Spring Boot Maven plugin

We can also add pom.xml file Add Maven plugin. It will package the project into an executable jar in the file.

<build>  
<plugins>  
<plugin>  
<groupId>org.springframework.boot</groupId>  
<artifactId>spring-boot-maven-plugin</artifactId>  
</plugin>  
</plugins>  
</build>

Spring Boot without parent POM

If we do not want to use spring-boot starter-parent If we want to use dependency management advantages but still use dependencies, we can use  Tags, as shown below:

Note: it does not maintain plugin management.
<dependencyManagement>
<dependencies>
<dependency> -- import dependency management from Spring Boot --
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

لا يسمح بتغطية هذه الاعتماديات. لتغطية، نحتاج إلى إضافة في المشروع}}  إضافة سطر إلى علامة التبويب spring-boot-dependencies قبل السطر المحدد.

على سبيل المثال، لتحديث آخر spring-data-releasetrain ، أضف依赖يات التالية في ملف pom.xml.

<dependencyManagement>
<dependencies>
<!--Override Spring Data release train-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Fowler-SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>