How to create bean using @Bean in spring boot for abstract class

前端 未结 3 577
旧巷少年郎
旧巷少年郎 2021-01-11 09:02

I have requirement to migrate old style spring project to Spring boot. Assume below code snippet I have to migrate to Spring boot style.

Here my ask , how to conver

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-11 09:42

    There is no need in converting this code. You only need to make the classes that extend com.test.core.common.AbstractClass declared as spring managed beans by either annotating them with @Component or @Service or declaring a method annotated with @Bean in your configuration class.

    Generally "abstract bean" is not needed in Java Configuration, there is even no equivalent. It was needed in xml configuration for parameter inheritance which is now achievable with plain java methods. Find example from Stephane Nicoll who is Spring Core developer.

提交回复
热议问题