Java : BeanCreationException: Error creating bean with name — Not a managed type

tanut aran
May 6, 2024

I spent hours searching for the answer and hope this help some random developer on the internet

Check the Import

Yes, this is 95% of the root cause

First The File Type with the SAME NAME

Because of Java extreme verbosity despite effort to reduce its,

You can easily mistakenly import file with WRONG TYPE BUT SAME NAME

Don’t be overwhelm with meaningless gigantic clueless stack trace

For example, you can mess up with the wrong import like this below:

import com.myclient.myproject.model.User;

import com.myclient.myproject.controller.User;

import com.myclient.myproject.utils.User;

Second The Package AGAIN WITH THE SAME NAME

Java have long history and some import and mistakenly OLD ONE WITH THE SAME NAME

For example, the new jakarta and the old javax

import jakarta.persistence.Entity

import javax.persistence.Entity

Hope this help !

--

--