Maven-Spring Boot Starter的版本 [英] Maven - version of Spring Boot Starter

查看:81
本文介绍了Maven-Spring Boot Starter的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是Spring Boot启动器版本的专家,并且遇到了问题.我正在尝试使用

插件版本错误

插件中的版本正确

解决方案

Spring Boot管理多个依赖项版本,以便我们确保它们彼此兼容.

查看此pom.xml文件,以查看Spring Boot 2.3.4.RELEASE管理哪些依赖项版本.您可以更改版本号并查看该版本中的托管依赖项.

this spring boot starter. And I need the embedded libraries version to be 5.2.0 as it says in description of this jar file. But when I added this dependency into my project I found that embedded libraries versions are different that I expected. My maven plugins shows that versions 5.1.6 and my code doesn't compile because some classes depend on methods from 5.2.0 module.

And there is one more thing. In another project I added the same dependency. But it's ok, versions are the same with description from maven repositoty. There is difference between these two project. One of them with spring-boot version 2.1.9 (which not compiles) and another - 2.3.4 (whihk works good). And when I checked versions of containing into starter libraries via artefactId in pom - they are ok and 5.2.0.

Here pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
    <artifactId>adapters</artifactId>
    <groupId>com.alarislabs</groupId>
    <version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>security</artifactId>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
        <version>2.2.0.RELEASE</version>
    </dependency>
</dependencies>

I've tried to delete m2 repo with all maven dependencies and then download again but I still have problem. I've made a mistake in pom.xml? Maybe is something wrong with my IntelliJ?

Versions of dependency in pom

Wrong versions in plugin

Correct versions in plugin

解决方案

Spring Boot manages several dependencies versions so that we can ensure they are compatible with each other.

Look at this pom.xml file to see which dependencies version are managed by Spring Boot 2.3.4.RELEASE. You can change the version number and see the managed dependencies in that version.

https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.3.4.RELEASE/spring-boot-dependencies-2.3.4.RELEASE.pom

Benefits:

  • If you want to use a dependency out of the dependency list, you do not need to specify the version in in your pom.xml. Or check if an official spring-boot-starter for that dependency exists. If it exists, just use the spring-boot-starter dependency. Again no need to specify the version.
  • Spring will pull the dependency that works well with all other libraries so that you won't get compatibility (runtime or compile time) error
  • When you upgrade spring boot's version, all the managed dependencies will get updated. And also the compatibility is maintained.

How to solve your problem:

In your pom.xml, you don't need to specify the version for spring-boot-starter-oauth2-resource-server. This library is managed by spring boot. It looks you are specifying version 2.2.0 which is not compatible with your spring boot version 2.1.9.

这篇关于Maven-Spring Boot Starter的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆