java jar运行依赖_仅在运行java -jar时发生循环依赖关系,而不是在使用spring-boot时运行:运行...

我一直在Intellij IDEA内开发一个弹簧引导应用程序。它现在已经完成,我即将把它发送给其他用户。仅在运行java -jar时发生循环依赖关系,而不是在使用spring-boot时运行:运行

我用mvn clean install构建它,并尝试用java -jar target/my-app.jar启动内置的jar文件。

令我吃惊的失败与一个异常(难读,但至少斩几行)

Exception encountered during context initialization - cancelling refresh attempt:

org.springframework.beans.factory.UnsatisfiedDependencyException:

Error creating bean with name 'userController':

Unsatisfied dependency expressed through field 'userClient';

nested exception is org.springframework.beans.factory.BeanCreationException:

Error creating bean with name '***.client.userclient.UserClient':

FactoryBean threw exception on object creation;

nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:

Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration':

Unsatisfied dependency expressed through method 'setConfigurers' parameter 0;

nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:

Error creating bean with name 'webMvcConfig':

Unsatisfied dependency expressed through field 'authenticationInterceptor';

nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:

Error creating bean with name 'authenticationInterceptor':

Unsatisfied dependency expressed through field 'authenticationClient';

nested exception is org.springframework.beans.factory.BeanCreationException:

Error creating bean with name '***.client.authenticationclient.AuthenticationClient':

FactoryBean threw exception on object creation;

nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException:

Error creating bean with name 'mvcResourceUrlProvider':

Requested bean is currently in creation: Is there an unresolvable circular reference?

我也得到了一些ASCII艺术上的依赖关系

***************************

APPLICATION FAILED TO START

***************************

Description:

The dependencies of some of the beans in the application context form a 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

└─────┘

所以我尝试运行它与mvn spring-boot:run,它的工作原理!

我以为java -jar和mvn spring-boot:run运行的印象是一样的。我错过了什么?

我想我可以修复循环依赖,但现在困扰我的是为什么这两个选手不同。

谢谢。

+0

你可能也有'mvn spring-boot:run'的问题,但你的配置允许循环引用(默认行为),而使用'java -jar'则有东西禁止它。 –

+0

如何控制该行为? –

+0

搜索谷歌这种类型的错误导致这个问题[使用\\EnableGlobalAuthentication或\\EnableAutoConfiguration类使用方法安全导致豆周期](https://github.com/spring-projects/spring-boot/issues/2578 )。可能与您的问题有关。你使用的是spring boot 1.2.2吗? :) –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值