Site Overlay

BUG记录:Error creating bean with name ‘xxx’ defined in file

该项目模块启动时在dubbo控制台中看不到注册成功,报出以下错误代码


21:51:41,326 DEBUG NioProviderMetadata:68 -  [DUBBO] Using the autodetected NIO constraint level: 0, dubbo version: 2.6.0, current host: 127.0.0.1
21:51:41,417  WARN XmlWebApplicationContext:558 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'albumServiceImpl' defined in file [E:\IDEA-workspace\qingcheng\qingcheng_parent\qingcheng_service_goods\target\classes\com\qingcheng\service\impl\AlbumServiceImpl.class]: Initialization of bean failed; nested exception is com.alibaba.dubbo.rpc.RpcException: Fail to start server(url: dubbo://192.168.11.1:20881/com.qingcheng.service.goods.AlbumService?anyhost=true&application=goods&bind.ip=192.168.11.1&bind.port=20881&channel.readonly.sent=true&codec=dubbo&dubbo=2.6.0&generic=false&heartbeat=60000&interface=com.qingcheng.service.goods.AlbumService&methods=add,findList,findById,update,findPage,delete,findAll&pid=10856&revision=1.0-SNAPSHOT&side=provider&timestamp=1571838700825) Failed to bind NettyServer on /192.168.11.1:20881, cause: Failed to bind to: /0.0.0.0:20881
21:51:41,418 DEBUG DefaultListableBeanFactory:499 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@f6b0fc2: defining beans [idWorker,dataSource,sqlSessionFactory,tk.mybatis.spring.mapper.MapperScannerConfigurer#0,transactionManager,org.springframework.transaction.config.internalTransactionalEventListenerFactory,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,dubbo,${dubbo.application},com.alibaba.dubbo.config.RegistryConfig,com.alibaba.dubbo.config.spring.AnnotationBean,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,albumMapper,auditMapper,brandMapper,categoryBrandMapper,categoryMapper,goodsLogMapper,paraMapper,prefMapper,skuMapper,specMapper,spuMapper,templateMapper,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,albumServiceImpl,brandServiceImpl,categoryServiceImpl,paraServiceImpl,prefServiceImpl,skuServiceImpl,specServiceImpl,spuServiceImpl,templateServiceImpl]; root of factory hierarchy
21:51:41,418 DEBUG DefaultListableBeanFactory:567 - Retrieved dependent beans for bean 'sqlSessionFactory': [albumMapper, auditMapper, brandMapper, categoryBrandMapper, categoryMapper, goodsLogMapper, paraMapper, prefMapper, skuMapper, specMapper, spuMapper, templateMapper]
21:51:41,418 DEBUG DefaultListableBeanFactory:567 - Retrieved dependent beans for bean 'com.github.pagehelper.PageHelper#2383feea': [sqlSessionFactory]
21:51:41,420 DEBUG DefaultListableBeanFactory:567 - Retrieved dependent beans for bean 'dataSource': [transactionManager]
21:51:41,421 DEBUG DisposableBeanAdapter:318 - Invoking destroy method 'close' on bean with name 'dataSource'
21:51:41,421 DEBUG DisposableBeanAdapter:246 - Invoking destroy() on bean with name 'com.alibaba.dubbo.config.spring.AnnotationBean'
21:51:41,425 ERROR ContextLoader:316 - Context initialization failed
  • 排除步骤:
  • 重新install多次
  • 排查包名接口名书写
  • 查看编译后文件
  • 查看Spring配置标注导包是否正确

重复多次后发现,某一个service模块能够启动成功,另一个就无法启动,想到是端口冲突,则去排查dubbo端口配置文件,结果发现提供的项目模块配置端口都一样的,所以导致dubbo中zookeeper只能注册成功一个,修改端口后则成功启动所有模块。

//dubbo.propertice配置文件

dubbo.port=20885
dubbo.application=config

发表回复

您的电子邮箱地址不会被公开。

A beliving heart is your magic My heart
欢迎来到Diuut的个人博客,这里是我的一些零零碎碎的知识汇总,希望有能帮到你的内容。 | 蜀ICP备2021011635号-1 | Copyright © 2024 Diuut. All Rights Reserved.