As soon as add Eureka Discover Client dependency to my Spring Boot Microservice that uses Axon, the application fails to start due to the following error.
Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'org.axonframework.spring.config.AxonConfiguration'; nested exception is java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, char, java.lang.Object)'
I get this error resolved by adding the following dependency:
com.google.guava
guava
30.1-jre
Just wanted to confirm with the Axon team if this is how it should be fixed or if there is another Axon Spring Boot starter I should use to make my Axon application work as Eureka client?
To make my Axon application Eureka client I use the following Eureka Dependency:
Axon doesn’t use Guava itself, but probably some transient dependencies do. There might be a versioning conflict between these transient dependencies, where the wrong one wins.
I know the grpc-java library uses Guava, and it comes in as a transient dependency via the AxonServer connector.
If you use Maven, you can run mvn dependency:tree to find out which dependencies modules have that may conflict with each other. You can override the version used by explicitly adding the dependency to your own project. Basically just like you did.
Had the same issue when trying to use Axon + Eureka client. Solved as follows. This lets Axon bring in the Guava dependency, which is better than specifying a particular one as a separate dependency.