eventuate-foundation / eventuate-common

Other
12 stars 20 forks source link

Spring Boot 2 vs. Spring Boot 3 - auto-configuration incompatibility #130

Open cer opened 1 year ago

cer commented 1 year ago

Originally posted by @cer in https://github.com/eventuate-foundation/eventuate-common/issues/129#issuecomment-1376265993

auto-configuration is not working currently in SB3 because the file has been moved to a new location and with a new name, https://github.com/spring-projects/spring-boot/issues/32566

/cc @kwonglau

cer commented 1 year ago

@kwonglau Isn't the solution to simply have both files: spring.factories and org.springframework.boot.autoconfigure.AutoConfiguration.imports?

kwonglau commented 1 year ago

yes.

auto configuration issue is an easy fix.

kwonglau commented 1 year ago

The configuration class in org.springframework.boot.autoconfigure.AutoConfiguration.imports has to mark as @AutoConfiguration instead of @Configuration. Otherwise; it will not pick up in spring boot 3.

https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfiguration.java

the annotation exists since 2.7.

cer commented 1 year ago

The configuration class in org.springframework.boot.autoconfigure.AutoConfiguration.imports has to mark as @AutoConfiguration instead of @Configuration. Otherwise; it will not pick up in spring boot 3.

Are you saying that auto configuration of Eventuate applications is not working because of this problem?

One possibility is to update the framework to require 2.7. That's currently the only (non-commercial) supported 2.x version

kwongpan commented 1 year ago

Correct. The auto config class doesn’t pick up in spring 3.1.1 unless I use the new annotation.

cer commented 1 year ago

Correct. The auto config class doesn’t pick up in spring 3.1.1 unless I use the new annotation.

I just tried an example (which uses autoconfiguration via the eventuate starters) with 3.1.2 and the build worked (locally): See https://github.com/eventuate-tram/eventuate-tram-sagas-examples-customers-and-orders/commit/3706088b4601101c0d92f3df3373179940ff34e1

There also this open Spring Boot issue: https://github.com/spring-projects/spring-boot/issues/35044

cer commented 1 year ago

Very strange. I had an autoconfiguration failure on a really small (private) project. I fixed it by changing Tram to use @AutoConfiguration.

kwongpan commented 1 year ago

I think the behavior is unpredictable. I recall that it was working when I was testing it with spring boot 3.0.1 back in January and it didn’t work when I was testing with spring boot 3.1.1 a few days ago.