会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132358个问题
JAVA 全系列/第二十阶段:租房网(Spring Cloud最新架构)/Livegoods第五天 61楼
JAVA 全系列/第二十阶段:租房网(Spring Cloud最新架构)/Livegoods第一天 64楼

老师您好,在启动LivegoodsGatewayApp时,提示如下错误信息。请问这个应该如何解决呢。谢谢!


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2020-07-08 02:37:12.389 ERROR 84132 --- [           main] o.s.boot.SpringApplication               : Application run failed


org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nettyReactiveWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration$EmbeddedNetty.class]: Unsatisfied dependency expressed through method 'nettyReactiveWebServerFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactorServerResourceFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration$EmbeddedNetty.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: io/netty/util/AttributeKey

at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:81) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

at com.livegoods.gateway.LivegoodsGatewayApplication.main(LivegoodsGatewayApplication.java:13) [classes/:na]

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nettyReactiveWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration$EmbeddedNetty.class]: Unsatisfied dependency expressed through method 'nettyReactiveWebServerFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactorServerResourceFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration$EmbeddedNetty.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: io/netty/util/AttributeKey

at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.getWebServerFactory(ReactiveWebServerApplicationContext.java:111) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.createWebServer(ReactiveWebServerApplicationContext.java:89) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:78) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

... 8 common frames omitted

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactorServerResourceFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration$EmbeddedNetty.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: io/netty/util/AttributeKey

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

... 20 common frames omitted

Caused by: java.lang.NoClassDefFoundError: io/netty/util/AttributeKey

at reactor.netty.resources.PooledConnectionProvider.<clinit>(PooledConnectionProvider.java:204) ~[reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE]

at reactor.netty.resources.ConnectionProvider$Builder.build(ConnectionProvider.java:439) ~[reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE]

at reactor.netty.resources.ConnectionProvider.fixed(ConnectionProvider.java:331) ~[reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE]

at reactor.netty.resources.ConnectionProvider.fixed(ConnectionProvider.java:272) ~[reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE]

at reactor.netty.resources.ConnectionProvider.fixed(ConnectionProvider.java:251) ~[reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE]

at reactor.netty.tcp.TcpResources.create(TcpResources.java:331) ~[reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE]

at reactor.netty.tcp.TcpResources.getOrCreate(TcpResources.java:275) ~[reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE]

at reactor.netty.http.HttpResources.get(HttpResources.java:42) ~[reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE]

at org.springframework.http.client.reactive.ReactorResourceFactory.afterPropertiesSet(ReactorResourceFactory.java:202) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]

... 31 common frames omitted

Caused by: java.lang.ClassNotFoundException: io.netty.util.AttributeKey

at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_211]

at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_211]

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_211]

at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_211]

... 42 common frames omitted


JAVA 全系列/第二十阶段:租房网(Spring Cloud最新架构)/Livegoods第一天 65楼

老师您好。我这个mongodb一开启auth=true, test中的代码执行完就会提示如下的unauthorized错误。我已经尝试了多种方式,包括多种yml中配置的格式,以及在@SpringBootApplication后面添加(exclude=...........)的这种写法,全都不管用。


后来删掉auth=true,就可以运行成功。而且很奇怪的是,开启用户认证后不光test中的代码会提示错误,就算在mongdb控制台中已经可以验证通过后再操作几分钟之后,mongdb控制台也会提示unauthorize的错误,类似db.shutdownServer()也无法执行了。好奇怪,请问这个有什么解决方式吗?


org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 13 (Unauthorized): 'not authorized on livegoods to execute command { insert: "banner", ordered: true, $db: "livegoods" }' on server 192.168.86.147:27017. The full response is {"ok": 0.0, "errmsg": "not authorized on livegoods to execute command { insert: \"banner\", ordered: true, $db: \"livegoods\" }", "code": 13, "codeName": "Unauthorized"}; nested exception is com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): 'not authorized on livegoods to execute command { insert: "banner", ordered: true, $db: "livegoods" }' on server 192.168.86.147:27017. The full response is {"ok": 0.0, "errmsg": "not authorized on livegoods to execute command { insert: \"banner\", ordered: true, $db: \"livegoods\" }", "code": 13, "codeName": "Unauthorized"}


at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:138)

at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2902)

at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:587)

at org.springframework.data.mongodb.core.MongoTemplate.insertDocumentList(MongoTemplate.java:1519)

at org.springframework.data.mongodb.core.MongoTemplate.doInsertBatch(MongoTemplate.java:1384)

at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:1308)

at com.livegoods.mongodb.TestDatas.insertBanners(TestDatas.java:51)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)

at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)

at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)

at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)

at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)

at org.junit.runner.JUnitCore.run(JUnitCore.java:137)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by: com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): 'not authorized on livegoods to execute command { insert: "banner", ordered: true, $db: "livegoods" }' on server 192.168.86.147:27017. The full response is {"ok": 0.0, "errmsg": "not authorized on livegoods to execute command { insert: \"banner\", ordered: true, $db: \"livegoods\" }", "code": 13, "codeName": "Unauthorized"}

at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:175)

at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:303)

at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:259)

at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99)

at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:450)

at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:72)

at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:218)

at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:269)

at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:131)

at com.mongodb.operation.MixedBulkWriteOperation.executeCommand(MixedBulkWriteOperation.java:435)

at com.mongodb.operation.MixedBulkWriteOperation.executeBulkWriteBatch(MixedBulkWriteOperation.java:261)

at com.mongodb.operation.MixedBulkWriteOperation.access$700(MixedBulkWriteOperation.java:72)

at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:205)

at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:196)

at com.mongodb.operation.OperationHelper.withReleasableConnection(OperationHelper.java:501)

at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:196)

at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:71)

at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:206)

at com.mongodb.client.internal.MongoCollectionImpl.executeInsertMany(MongoCollectionImpl.java:524)

at com.mongodb.client.internal.MongoCollectionImpl.insertMany(MongoCollectionImpl.java:508)

at com.mongodb.client.internal.MongoCollectionImpl.insertMany(MongoCollectionImpl.java:503)

at org.springframework.data.mongodb.core.MongoTemplate.lambda$insertDocumentList$17(MongoTemplate.java:1526)

at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:585)

... 34 more


JAVA 全系列/第二十阶段:租房网(Spring Cloud最新架构)/Livegoods第一天 66楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637