Cyclic dependency only when running java -jar, not with spring-boot:run -


i've been developing spring-boot application inside intellij idea while. it's complete , i'm send of other users.

i build mvn clean install , try start built -jar file java -jar target/my-app.jar.

to surprise fails exception (hard read @ least chopped several lines)

exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'usercontroller': unsatisfied dependency expressed through field 'userclient'; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name '***.client.userclient.userclient': factorybean threw exception on object creation; nested exception org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'org.springframework.boot.autoconfigure.web.webmvcautoconfiguration$enablewebmvcconfiguration': unsatisfied dependency expressed through method 'setconfigurers' parameter 0; nested exception org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'webmvcconfig': unsatisfied dependency expressed through field 'authenticationinterceptor'; nested exception org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'authenticationinterceptor': unsatisfied dependency expressed through field 'authenticationclient'; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name '***.client.authenticationclient.authenticationclient': factorybean threw exception on object creation; nested exception org.springframework.beans.factory.beancurrentlyincreationexception: error creating bean name 'mvcresourceurlprovider': requested bean in creation: there unresolvable circular reference? 

i ascii art on dependencies

*************************** application failed start ***************************  description:  dependencies of of beans in application context form cycle:  |  usercontroller (field ****.client.userclient.userclient ****.controller.user.usercontroller.userclient) ↑     ↓ |  ****.client.userclient.userclient ↑     ↓ |  org.springframework.boot.autoconfigure.web.webmvcautoconfiguration$enablewebmvcconfiguration ↑     ↓ |  webmvcconfig (field ****.authenticationinterceptor ****.webmvcconfig.authenticationinterceptor) ↑     ↓ |  authenticationinterceptor (field ****.client.authenticationclient.authenticationclient ****.authenticationinterceptor.authenticationclient) ↑     ↓ |  ****.client.authenticationclient.authenticationclient ↑     ↓ |  mvcresourceurlprovider └─────┘ 

so try run mvn spring-boot:run , works!

i under impression running java -jar , mvn spring-boot:run same. missing?

i guess fix cyclic dependencies bothers me why these 2 runners differ.

thanks.

you have use maven-shade-plugin or similar pack dependencies standalone use. sure want run jar standalone , not build war , deploy application server apache tomcat?


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -