Spring can you autowire inside an abstract class?

后端 未结 4 2002
长情又很酷
长情又很酷 2020-11-30 02:14

Spring is failing to autowire my object? Is it possible to autowire an object within an abstract class. Assume all schemas are supplied in application-context.xml

Qu

4条回答
  •  醉酒成梦
    2020-11-30 02:46

    Normally, Spring should do the autowiring, as long as your abstract class is in the base-package provided for component scan.

    See this and this for further reference.

    @Service and @Component are both stereotypes that creates beans of the annotated type inside the Spring container. As Spring Docs state,

    This annotation serves as a specialization of @Component, allowing for implementation classes to be autodetected through classpath scanning.

提交回复
热议问题