whuzjn 2020-06-15 16:09 采纳率: 0%
浏览 2174

Springboot覆盖引用jar包中的类,在启动时报找不到bean异常

我在A工程中引入了B.jar(由B工程执行maven-install打包而来),使用了B中的Service,我想在A工程中重写B工程中的“CustomerButtonService”类,但是将B工程中的“CustomerButtonService”类拷贝到A工程中后,在启动A工程时,初始化“customerButtonController”时报了下面的异常,在线求救中。
2020-06-15 15:46:08,761 [restartedMain] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext 557 - Exception encountered dur
ing context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating be
an with name 'customerButtonController': Unsatisfied dependency expressed through field 'customerButtonService'; nested exception is org.spr
ingframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.test.os.management.customerButton.service.Custo
merButtonService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.b
eans.factory.annotation.Autowired(required=true)}


APPLICATION FAILED TO START


Description:

Field customerButtonService in com.test.os.management.customerButton.controller.CustomerButtonController required a bean of type 'com.test.os.management.customerButton.service.CustomerButtonService' that could not be found.

Action:

Consider defining a bean of type 'com.test.os.management.customerButton.service.CustomerButtonService' in your configuration.

谢谢“Timor_D”的回答,我按照您的建议查了一遍,都没有问题,不过在检查过程中发现我A工程的pom.xml文件里引入了【devtools】工具,去掉下面这个引用就好了

    <!-- spring boot devtools -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
  • 写回答

2条回答 默认 最新

  • Timor_D 2020-06-15 16:24
    关注

    service上面加@service注解了吗?

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog