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

2022-11-22 19:57:07 浏览数 (1)

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

代码语言:javascript复制
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-workspaceqingchengqingcheng_parentqingcheng_service_goodstargetclassescomqingchengserviceimplAlbumServiceImpl.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只能注册成功一个,修改端口后则成功启动所有模块。

代码语言:javascript复制
//dubbo.propertice配置文件

dubbo.port=20885
dubbo.application=config

Post Views: 228

0 人点赞