No or more beans found in the Spring context for a class of type ... myPackageHere ..., skipping type

My Java Java classes are as follows:

@Component ...class...MyComponent...extends myParent 

And in the parent class:

 ...abstract class myParent... @Autowired SomeBean myAutowiredBean 

I get some strange warnings when my server starts:

November 14, 2014 10:41:23 org.glassfish.jersey.server.spring.SpringComponentProvider bind SEVERE: No or more beans were found in the Spring context for a class like ... myPackageAndClassHere ..., skipping the type.

Despite the warning, everything works as intended. This warning applies to every class extending the parent. Is this due to the abstract nature of the parent class?

I found this page where someone has a similar problem , is this a jersey / spring issue? I am using Jersey 2.11 and Spring 3.2.3.

+5
source share
1 answer

I ran into the same problem. My REST resources answered correctly, but I received the same SEVERE message. In fact, if you are trying to embed some of my beans in some of the REST services, I got a NullPointerException on any bean call.

It so happened that the jersey initialized the rest of the services, but did not initialize my spring beans (let me say ... right, I had to !!)

I decided to just make spring aware of my bean :)

Just add context: component-scan base-package = "myPackage"

The warning (and NullPointers) is gone!

+3
source

Source: https://habr.com/ru/post/1206867/


All Articles