Podbicie wersji springa powoduje problem z wersjami zależności w maven

0

W jendym z projektów próbuję podbić wersję springa do wersji 5.2.20.RELEASE (ze względu na podatność).
Próbowałem podbić spring boota do wersji 2.5.12 natomiast od razu zauważyłem problemy z kompatybilnością
zależności/bibliotek, błędy w runtime więc uznałem tę zmianę za dużą i zbyt ryzykowną.
Aktualnie aby podbić wersję springa do poma dodałem:

<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-core</artifactId>
	<version>5.2.20.RELEASE</version>
</dependency>
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-web</artifactId>
	<version>5.2.20.RELEASE</version>
</dependency>
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-jms</artifactId>
	<version>5.2.20.RELEASE</version>
</dependency>
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-aop</artifactId>
	<version>5.2.20.RELEASE</version>
</dependency>
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-test</artifactId>
	<version>5.2.20.RELEASE</version>
</dependency>
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-context</artifactId>
	<version>5.2.20.RELEASE</version>
</dependency>

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
		</exclusion>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
		</exclusion>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
		</exclusion>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-activemq</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jms</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
		</exclusion>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
		</exclusion>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
		</exclusion>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-json</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<exclusions>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-aop</artifactId>
	</exclusion>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-web</artifactId>
	</exclusion>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-core</artifactId>
	</exclusion>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-context</artifactId>
	</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
<exclusions>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-web</artifactId>
	</exclusion>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-core</artifactId>
	</exclusion>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-aop</artifactId>
	</exclusion>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-context</artifactId>
	</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<exclusions>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-core</artifactId>
	</exclusion>
	<exclusion>
		<groupId>org.springframework</groupId>
		<artifactId>spring-context</artifactId>
	</exclusion>
</exclusions>
</dependency>

Maven sypie takimi błędami:

[WARNING]
Dependency convergence error for org.springframework:spring-aop:5.2.20.RELEASE paths to dependency are:
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-aop:5.2.20.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-context:5.2.20.RELEASE
    +-org.springframework:spring-aop:5.2.7.RELEASE

[WARNING]
Dependency convergence error for org.springframework:spring-core:5.2.20.RELEASE paths to dependency are:
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-core:5.2.20.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-web:5.2.20.RELEASE
    +-org.springframework:spring-beans:5.2.7.RELEASE
      +-org.springframework:spring-core:5.2.7.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-web:5.2.20.RELEASE
    +-org.springframework:spring-core:5.2.7.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-jms:5.2.20.RELEASE
    +-org.springframework:spring-core:5.2.7.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-jms:5.2.20.RELEASE
    +-org.springframework:spring-messaging:5.2.7.RELEASE
      +-org.springframework:spring-core:5.2.7.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-jms:5.2.20.RELEASE
    +-org.springframework:spring-tx:5.2.7.RELEASE
      +-org.springframework:spring-core:5.2.7.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-aop:5.2.20.RELEASE
    +-org.springframework:spring-core:5.2.7.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-test:5.2.20.RELEASE
    +-org.springframework:spring-core:5.2.7.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-context:5.2.20.RELEASE
    +-org.springframework:spring-core:5.2.7.RELEASE
and
+-myproject:0.0.1-SNAPSHOT
  +-org.springframework:spring-context:5.2.20.RELEASE
    +-org.springframework:spring-expression:5.2.7.RELEASE
      +-org.springframework:spring-core:5.2.7.RELEASE

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability. See above detailed error message.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.808 s
[INFO] Finished at: 2022-04-04T18:32:03+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce (enforce) on project partyapi: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Nie rozumiem tego. Przecież jak wejdę do poma to jak wół jest, że np. spring-aop:5.2.20.RELEASE zależy od spring-core:5.2.20.RELEASE a nie od spring-core:5.2.7.RELEASE.
Jak rozwiązać ten problem? A może jest jakiś lepszy sposób na podbicie wersji springa?

0

Problem chyba rozwiązany. Wystarczy nadpisać property:

<spring-framework.version>5.2.20.RELEASE</spring-framework.version>

Natomiast nadal nie rozumiem dlaczego w poprzednim rozwiązaniu maven mówi, że spring-aop:5.2.20.RELEASE zależy od spring-core:5.2.7.RELEASE skoro tak nie jest.

0

Effective POM i dependency tree sprawdzone? Wszystko by się wyjaśniło.

3

Jest jakiś powód czemu nie masz jakiegoś

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>X.Y.Z.RELEASE</version>
    </parent>

a resztę wersji niech już sobie spring sam ogarnie?

0

@raxigan: Urywek z dependency:tree

[INFO] \- org.springframework:spring-context:jar:5.2.20.RELEASE:compile
[INFO]    \- org.springframework:spring-expression:jar:5.2.7.RELEASE:compile

@Shalom:
Jest:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.1.RELEASE</version>
    </parent>

Natomiast wersja 2.3.1.RELEASE zależy od springa w wersji 5.2.7 stąd

<spring-framework.version>5.2.20.RELEASE</spring-framework.version>

aby podbić do nowszej wersji springa, która ma fixa na tę podatność a reszta zależności, które
dostajemy w ramach spring boota pozostaje bez zmian. Podbicie wersji spring boota z 2.3.1 do 2.5.12
to jest imo spora zmiana w bebechach są jeszcze większe problemy z zależnościami, które jak poprawiłem
to i tak potem w runtime się wywala bo jakichś klas/metod/pakietów brakuje.
Podbicie samego springa 5.2.7 -> 5.2.20 jest raczej mniej inwazyjne a przynajmniej jak odpaliłem build z testami wszystko ok.

1 użytkowników online, w tym zalogowanych: 0, gości: 1