thomasdarimont / embedded-spring-boot-keycloak-server

Keycloak JAX-RS application embedded in a Spring-Boot App.
Apache License 2.0
287 stars 112 forks source link

Incompatible with Eureka Discovery Client #32

Open cedbesafilm opened 4 years ago

cedbesafilm commented 4 years ago

I was trying to add Eureka Discovery Client to a project but I get this error at runtime

image

So i try to exclude the dependency but without luck

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-ribbon</artifactId>
    </exclusion>
    <exclusion>
      <groupId>com.netflix.ribbon</groupId>
      <artifactId>ribbon-eureka</artifactId>
    </exclusion>
    <exclusion>
      <groupId>javax.ws.rs</groupId>
      <artifactId>jsr311-api</artifactId>
    </exclusion>
  </exclusions>
</dependency>

There are some workaround for this or they are simply incompatible?

Michal-Kucera commented 3 years ago

I managed to get that working by excluding javax.ws.rs from Eureka client dependency in build.gradle file:

implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client' exclude group: 'javax.ws.rs'

My setup is org.springframework.boot 2.4.2, spring-cloud-dependencies 2020.0.1, embedded keycloak 2.4.0.

You may try a similar approach with Maven.

FYI check out https://gitlab.com/spring-cloud-infrastructure/authorization-server/-/blob/master/build.gradle#L41 for more info.

cedbesafilm commented 3 years ago

Later in the project i start to use docker version of keycloak :)

Michal-Kucera commented 3 years ago

Yeah, I found that as a suitable solution as well, however, I still feel more comfortable with embedding it, especially when I want to do some custom magic around, such as externalize configuration with Spring Config Server, distributed tracing with Sleuth and Zipkin, or implementing a custom Protocol Mapper, etc..

cedbesafilm commented 3 years ago

Maybe in the future they would be nice things to try but for the current state of the project the docker container is the ideal solution since we don't have big needs and it also integrates well with the library we use for authentication with Angular at the expense of discovery, admin, tracing, etc ...