Spring Boot-嵌套异常是org.springframework.beans.factory.nosuchbeandefinitionException:没有合格的类型bean''可用的

发布于 2025-01-26 20:55:09 字数 1459 浏览 3 评论 0原文

我正在尝试将以下语句添加到Spring Boot服务:

@Autowired 
private ApELDatabasePublisherService eventPublisher;

EventPublisher的依赖性在此JAR文件中包含:

.m2\repository\com\xxxx\bip\bip-event-logging\1.5.3.7-RELEASE.jar

它编译,构建和更新本地Maven存储库,但是当我启动应用程序时,它将终止于错误消息。

最初,错误消息是这样的:

No qualifying bean of type 'com.xxxx.bip.components.el.services.ApELDatabasePublisherService' available

但是,当我添加com.xxxx.bip.components.el.services中时,它消失了。

下一个消息是:

No qualifying bean of type 'com.xxxx.bip.components.el.dao.services.IApElTypeNameLookupService' available:

所以我添加了com.xxxx.bip.components.el.dao.services到组件扫描,并且该错误消失了。

但是现在我有第三条消息不会消失,如下所示:

No qualifying bean of type 'com.xxxx.bip.components.el.repository.IApELEventTypeRepository' available

即使我将以下内容添加到组件扫描时,此消息仍保留:

com.xxxx.bip.components.el.repository

因此,我的当前扫描看起来像这样:

@EnableRetry
@EnableScheduling
@SpringBootApplication(exclude = { HibernateJpaAutoConfiguration.class })
@ComponentScan(basePackages = {
        "com.xxxx.bip.components.el.services",
        "com.xxxx.bip.components.el.dao.services",
        "com.xxxx.bip.components.el.repository",

我已经验证了所讨论的类,> iApeleventtyperepository包含在JAR文件中,并注释为“ @repository”,

为什么当它找到前两个软件包时它找不到它?

I'm trying to add the following statement to a Spring Boot service:

@Autowired 
private ApELDatabasePublisherService eventPublisher;

The dependency for eventPublisher is contained in maven, in this jar file:

.m2\repository\com\xxxx\bip\bip-event-logging\1.5.3.7-RELEASE.jar

It compiles, builds and updates the local maven repository, but when I launch the application, it terminates with an error message.

Initially, the error message was this:

No qualifying bean of type 'com.xxxx.bip.components.el.services.ApELDatabasePublisherService' available

However, that disappeared when I added com.xxxx.bip.components.el.services to the component scan.

The next message was this:

No qualifying bean of type 'com.xxxx.bip.components.el.dao.services.IApElTypeNameLookupService' available:

So I added com.xxxx.bip.components.el.dao.services to the component scan, and that error went away.

But now I have a third message which is not going away, as follows:

No qualifying bean of type 'com.xxxx.bip.components.el.repository.IApELEventTypeRepository' available

This message stays even when I add the following to component scan:

com.xxxx.bip.components.el.repository

So my current scan looks like this:

@EnableRetry
@EnableScheduling
@SpringBootApplication(exclude = { HibernateJpaAutoConfiguration.class })
@ComponentScan(basePackages = {
        "com.xxxx.bip.components.el.services",
        "com.xxxx.bip.components.el.dao.services",
        "com.xxxx.bip.components.el.repository",

I've verified that the class in question, IApELEventTypeRepository is included in the jar file and is annotated as "@Repository"

Why would it not find it when it finds the previous two packages?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜警司 2025-02-02 20:55:09

由于您正在使用另一个软件包中的存储库/entites工作,因此它找不到存储库来为其进行默认实现。

尝试添加您的配置

@EnableJpaRepositories(basePackages="<repository package name>")

,很可能需要添加注释,以便春季可以找到实体。

@EntityScan("packages")

Since you are working with the repositories/entites located in the another package than spring application, it can't find repositories in order to make a default implementations for them.

Try to add to your configuration

@EnableJpaRepositories(basePackages="<repository package name>")

And most probably, you will need to add annotation, so that Spring can find entities.

@EntityScan("packages")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文