【问题标题】:intellij idea reports cannot autowire beans for custom spring-boot-starter moduleIntellij IDEA 报告无法为自定义 spring-boot-starter 模块自动装配 bean
【发布时间】:2019-03-06 04:56:23
【问题描述】:

我有 2 个启动模块:spring-boot-starter-vertx 和 spring-boot-starter-vertx-consul

consul starter 依赖于 vertx starter

Intellij idea 报告它无法为 consul 启动模块自动装配 Vertx bean(它在 vertx 启动模块中定义)

但所有模块都由 maven 成功构建和运行(包括模块使用 vertx 和 consul 启动器)

如何判断 Vertx bean 是由另一个模块提供的以避免错误报告? (我添加了 ConditionalOnBean 但错误仍然存​​在)

【问题讨论】:

    标签: java spring maven spring-boot intellij-idea


    【解决方案1】:

    我认为您需要在 Intellij Idea 中定义模块的依赖关系。这样,Intellij 以预定义的顺序构建模块并将它们设置在类路径中。

    更多信息: https://www.jetbrains.com/help/idea/creating-and-managing-modules.html#working-with-module-dependencies

    【讨论】:

    • 我尝试在一个模块中定义两个配置,idea还是报这个错误...
    • 对了,模块依赖已经存在(maven管理)
    • @rainmanhhh 在 Intellij 中构建与使用 Maven 编译不同,因此在 Maven 中定义依赖关系不会影响 IDE 构建。当您在 Intellij 中定义依赖顺序时,它知道应该首先构建哪个模块并将其放入其他模块的类路径中。
    【解决方案2】:

    通过 ConsulConfiguration 上的 @Import(VertxConfiguration.class) 解决

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-11
      • 2020-01-31
      • 1970-01-01
      • 2016-09-27
      • 1970-01-01
      • 2014-08-18
      • 2019-12-31
      相关资源
      最近更新 更多