Spring, abstract class and annotations

后端 未结 2 732
执笔经年
执笔经年 2020-12-09 16:10

I\'ve got a pretty simple abstract class

public abstract class AbstractServiceActions {

    @Autowired
    protected DatabaseModel dbModel;

    protected U         


        
相关标签:
2条回答
  • 2020-12-09 16:20

    Your setup seems fine. The reason perhaps lies elsewhere. Maybe you are instantiating the class with new CreateDatabaseAction(), rather than letting spring do this.

    0 讨论(0)
  • 2020-12-09 16:42

    Use @Autowired and not @Inject from javax.inject.

    Dependency injection in abstract class only works for spring's @Autowired.

    FYI, I'm using Spring 4.0; Java 6

    0 讨论(0)
提交回复
热议问题