Search code examples
spring-bootnetflix-zuulspring-cloud-netflix

Correct dependency management with Spring Zuul and Spring Initializer


I want to implement some hello world Spring Zuul project based on Baeldung and this pt-br blog.

As the first uses this non-Spring artifact

<groupId>com.baeldung.spring.cloud</groupId>
<artifactId>spring-cloud</artifactId>

as parent and the second uses this deprecated artifact at dependencyManagement, I decided to use spring initalizr only adding Zuul to my dependencies. But when I run it, I get this exception:

Caused by: java.lang.ClassNotFoundException: com.netflix.zuul.monitoring.CounterFactory

I'm using this annotations at my main class:

@SpringBootApplication
@EnableZuulProxy
@EnableDiscoveryClient

Solution

  • Since I had already tried to delete .m2 folder and this didn't work, I assume my download didn't complete successfully again. But my error changed to

    Caused by: java.lang.ClassNotFoundException: com.netflix.zuul.ZuulFilter
    

    followed by

    Caused by: java.util.zip.ZipException: invalid block type
    

    That turned this error is commonly caused by invalid .m2 jars.

    After deleting everything at .m2 with 'zuul' on it, including com/netflix/zuul(outside spring directory), and using mvn clean package -U with maven 3.5.4 I finally successfully initiated my application.