Martin Baeumer
Martin Baeumer

Reputation: 189

Spring Boot 2 fails starting due to Hystrix?

I started investigating to migrate a Spring Boot application from 1.5.x to 2. This appliication has a dependency to hystrix, which does not be compatible to Spring Boot 2 yet. When I have the following in my pom:

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-hystrix</artifactId>
  <version>1.4.4.RELEASE</version>
</dependency>

I get the following error when starting the application:

java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:125)

Anybody has experienced the same? Is there a solution yet?

Upvotes: 12

Views: 13663

Answers (6)

anand krish
anand krish

Reputation: 4415

For SpringBoot 2.0 version artifactID has been changed. Old dependency is

     <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-hystrix</artifactId>
          <version>${spring-hystrix.version}</version>
     </dependency>

Use this new updated dependency with latest version

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        <version>2.2.8.RELEASE</version>
    </dependency>

for recent release version you can check MVNrepository

Upvotes: 4

Tsvetoslav Tsvetkov
Tsvetoslav Tsvetkov

Reputation: 1176

After some time spent on researching and testing, here is what I found and noticed

I think that in the latest Spring Boot version (2.5.x), the Hystrix looks to be deprecated or I just couldn't find out way to add it as a dependency. Spring boot 2.5.x

So I downgraded the Spring boot version to 2.3.x where I managed to run the application Spring boot 2.3.x

So here is how my working pom.xml looks like:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.12.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.hldservices</groupId>
<artifactId>payment-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringCloudPaymentCircuitBreakerApplication</name>
<description>Demo project for Spring Boot</description>
<properties>
    <java.version>11</java.version>
    <spring-cloud.version>Hoxton.SR11</spring-cloud.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Keep in mind that I had to add following configuration in my Project:

SpringCloudPaymentCircuitBreakerApplication(main class)

@EnableHystrix
@EnableHystrixDashboard

application.propreties

management.endpoints.web.exposure.include=*
hystrix.dashboard.proxyStreamAllowList=*

Upvotes: 0

Tun&#231; Ikikardes
Tun&#231; Ikikardes

Reputation: 41

I faced a similar problem with Spring Boot 2, concisely 2.2.0.RELEASE. My mvn project compiled well but Spring Boot application stopped starting, without showing any real hints.

The solution that worked was using the artifact spring-cloud-starter-netflix-hystrix instead of spring-cloud-starter-hystrix from the same group. Then you can use the same same version as Spring Boot to retrieve the dependency.

From old pom.xml :

<!-- hysterix -->
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-hystrix</artifactId>
  <version>1.4.7.RELEASE</version>
</dependency>

New part in working pom.xml:

<!-- hysterix -->
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
  <version>${spring.boot.version}</version>
</dependency>

Upvotes: 3

Parthi P
Parthi P

Reputation: 131

I have faced similar issue while integrating hystrix for my spring boot microservice that uses spring boot 2.0.x. Instead of

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
    <version>${spring-hystrix.version}</version>
</dependency>

I have moved to

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    <version>${spring-hystrix.version}</version>
</dependency>

Spring boot 2.0.x application starts fine with the spring-cloud-starter-netflix-hystrix dependency without this issue.

Upvotes: 7

Niyi Oyelade
Niyi Oyelade

Reputation: 31

I had this problem starting Spring Boot 2 as well because spring-cloud-starter-hystrix was a dependency I used in my project. However I found that spring-cloud-starter-hystrix has been deprecated. I also found the feign classes I was using in there have been moved to spring-cloud-openfeign (https://github.com/spring-cloud/spring-cloud-openfeign). So all I did was remove spring-cloud-starter-hystrix from my dependency and added spring-cloud-openfeign instead. This works perfectly for me.

Basically I replaced

compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-hystrix', version: '1.4.4.RELEASE'

with

compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '2.0.0.RELEASE'

and Spring Boot 2 is ready to go. Hope this helps.

NB: I use Gradle, you can easily find the maven pom dependency equivalents if necessary.

Upvotes: 3

Martin Baeumer
Martin Baeumer

Reputation: 189

After a bit further research I found a solution by adding the following to the pom file:

<dependencyManagement>
  <dependencies>
      <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-dependencies</artifactId>
          <version>Finchley.RC1</version>
          <type>pom</type>
          <scope>import</scope>
      </dependency>
   </dependencies>
</dependencyManagement>

all versions of spring-cloud-dependenciesseem to be incompatible to Spring Boot 2.x.x

Upvotes: 3

Related Questions