I have a working Spring boot app. I changed the application to read its configuration from Spring Cloud Config server. I added bootstrap.properties and the following dependencies to the pom:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
The version of spring cloud is 2020.0.4. The app successfully retrieves its configuration from the config server. However, the endpoints fail with the following error:
in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: 'void javax.ws.rs.core.MultivaluedMap.addAll(java.lang.Object, java.lang.Object[])'] with root cause
java.lang.NoSuchMethodError: 'void javax.ws.rs.core.MultivaluedMap.addAll(java.lang.Object, java.lang.Object[])'
I have run the boot application in debug mode to see what the Tomcat classpath is. Prior to adding Spring Cloud Config , there was only
jakarta.ws.rs-api-2.1.6.jar
on the classpath. However after adding the config server dependencies
jsr311-api-1.1.1.jar
is showing up on the Tomcat classpath before the Jakarta library and hence why this is happening.
I am not sure why the addition of Spring Cloud Config dependencies to my pom and adding a property file would cause this addition to the classpath.
I am running/building the app using mvn spring-boot:run.
How do I fix this issue?
Update: it seems that the jsr311-api-1.1.1.jar
gets pulled in by spring-cloud-starter-netflix-eureka-client
Thank you.