Skip to content

BeanCurrentlyInCreationException error depends on @ComponentScan basePackages values order [SPR-14307] #18879

@spring-projects-issues

Description

@spring-projects-issues

István pató opened SPR-14307 and commented

spring-projects/spring-boot#6045

We have an issue with 'circular reference' error. When I started my Spring Boot app on my Ubuntu 16.04 desktop OS, the issue is not showing up. If I running the app on the Ubuntu 16.10 Server OS, then I get an error:

Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'exampleService': Requested bean is currently in creation: Is there an unresolvable circular reference?

If I change

@ComponentScan(basePackages = "org.springframework.boot.issues.ghXXXX")

to

@ComponentScan(basePackages = {"org.springframework.boot.issues.ghXXXX.server", "org.springframework.boot.issues.ghXXXX.service", "org.springframework.boot.issues.ghXXXX"})

then I don't get BeanCurrentlyInCreationException on Ubuntu 16.10 Server OS.

I can reproduce the issue with a maven project. The code is failing on same OS, if I change @ComponentScan basePackages order.


Affects: 4.2.6

Reference URL: https://github.com/patoi/spring-boot-issues/tree/gh-6045/gh-6045

3 votes, 6 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions