4

I have built simple microservice application using Spring-Boot and Eureka server. Now, I want to add fault-tolerance in case any of service registered in Eureka server is down. So, I used netflix-hystrix gradle dependency. But that dependency caused my application to crash.

I am getting following error message when running application:

Execution failed for task ':compileJava'. Could not resolve all files for configuration ':compileClasspath'. Could not find org.springframework.cloud:spring-cloud-starter-netflix-hystrix:.

For reference I have added snippet of build.gradle file.

plugins {
    id 'org.springframework.boot' version '2.4.4'
}

ext {
    set('springCloudVersion', "2020.0.2")
}

dependencies {
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}
Ajay
  • 917
  • 3
  • 12
  • 26

2 Answers2

5

I believe you should also specify the version of the dependency:

implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix', version: '2.2.7.RELEASE'
Cosmin Ioniță
  • 3,598
  • 4
  • 23
  • 48
  • This worked, but I have specified the version in snippet section like mentioned in question above. Is there something to do with version compatibility? Since for eureka server I specified version like mentioned above, it worked but not in case of hystrix dependency. Any reasons? – Ajay Mar 25 '21 at 11:36
  • You can use that variable for the version, like that: `implementation 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix:${springCloudVersion}'` – Cosmin Ioniță Mar 25 '21 at 11:41
  • 1
    You sure the version is set correctly? It should be one of the versions on [mavenCentral](https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix) for that package, which is different than the one you currently use (`2020.0.2`) – Cosmin Ioniță Mar 25 '21 at 13:34
  • 3
    The available versions for `spring-cloud-starter-netflix-hystrix` can be checked [here](https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix), and the ones for `spring-cloud-dependencies` can be checked [here](https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies). So you should simply add a new variable, like `set('springHystrixVersion', "2.2.7.RELEASE")`, and use it when you fetch the package: `implementation 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix:${springHystrixVersion}'` – Cosmin Ioniță Mar 25 '21 at 13:36
  • 1
    Please refer to below links, it's about `Spring Cloud Netflix Projects Entering Maintenance Mode` and it seems we should manually specify version of `spring-cloud-starter-netflix-hystrix` if we use the latest `spring-cloud-dependencies`: https://github.com/spring-cloud/spring-cloud-release/wiki/Spring-Cloud-2020.0-Release-Notes https://spring.io/blog/2018/12/12/spring-cloud-greenwich-rc1-available-now#spring-cloud-netflix-projects-entering-maintenance-mode – mazend Apr 19 '21 at 09:07
2

I had the same issue and found this official link where they say:

As announced, the following modules have been removed from spring-cloud-netflix:

  • ...
  • spring-cloud-netflix-hystrix
  • spring-cloud-starter-netflix-hystrix
  • ... (some other spring-cloud-netflix-* subprojects)

So it appears that Hystrix dependency will no longer be managed by spring-cloud-release. That's why you have to manually specify version. Anyway it doesn't mean that Spring Hystrix is/will be deprecated but i don't know that part yet...

I'm answering this question now because i found it after digging a lot and don't want anyone has to do it again.

PedroRodP
  • 21
  • 1