Can I have Spring's @Component on enum?

前端 未结 2 1466
失恋的感觉
失恋的感觉 2020-12-31 03:28

I\'m using Spring 3.0.x and following the enum singleton pattern for one of my implementatons.

public enum Person implements Nameable {
    INSTANCE;

    pu         


        
2条回答
  •  粉色の甜心
    2020-12-31 04:10

    You won't need to use the enum singleton pattern if you're using Spring to manage dependency injection. You can change your Person to a normal class. Spring will use the default scope of singleton, so all Spring-injected objects will get the same instance.

提交回复
热议问题