nmpg
nmpg

Reputation: 601

Convert a Spring MVC application to Spring Boot - BeanCurrentlyInCreationException issue

I have a Spring MVC application, using Hibernate for my entities persistence management. I am able to build, deploy and run it on some application server such as glashfish or tomcat, all is fine.

Now, I want to convert it into a Spring Boot application. I added the following class:

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) {
        ConfigurableApplicationContext context = 
                            SpringApplication.run(Application.class, args);
    }
}

and added the spring-boot, spring-boot-autoconfigure, and spring-boot-starter-tomcat dependencies to my pom.

Alas, when trying to run the application, I get the following error:

BeanCurrentlyInCreationException: Error creating bean with name
'MyClassDAO': Bean with name 'MyClassDAO' has been injected into 
other beans [MyOtherClassDAO] in its raw version as part of a circular
reference, but has eventually been wrapped. This means that said other
beans do not use the final version of the bean. This is often the result
of over-eager type matching - consider using 'getBeanNamesOfType' with 
the 'allowEagerInit' flag turned off, for example.

I don't know how to use 'getBeanNamesOfType' and set the allowEagerInit off (I do not use XML configuration). Of course, I'm not sure this would solve my issue anyway.

Any ideas on how I can fix this?

Upvotes: 0

Views: 559

Answers (1)

Amit Mishra
Amit Mishra

Reputation: 510

If it's really some intilization issue then i believe the you must be having your class in other package and due to some cache issues it doesn't include those classes in class path to scan in container so to do this manually you can put a annotation just below @springbootapllication is @EnableComponentScan("enter the package name of the class which is not initializing") also on that dao class put @service or @component annotation to let the application include then in container

Upvotes: 0

Related Questions