在K8s上部署一套java程序,业务端无法访问,于是通过控制台打印日志显示如下:

[root@k8s01 temp]# kubectl logs -f cm-debit-card-plat-search-0
The bean 'beanNameViewResolver', defined in class path resource [cn/afterturn/easypoi/configuration/EasyPoiAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class] and overriding is disabled.

主要原因为项目的类名与项目引用基础包中的beamname冲突导致该错误!
解决办法:
在项目配置文件中添加重写beamname的配置

main:
    allow-bean-definition-overriding: true

完整配置如下:

server:
  tomcat:
    uri-encoding: UTF-8
    max-threads: 1000
    min-spare-threads: 30
  port: 8080
  servlet:
    context-path: /*********
spring:
  main:
    allow-bean-definition-overriding: true
  mvc:
    servlet:
      load-on-startup: 100
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    druid:

修改后重新发布程序上线,完美启动。

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐