I've got a pretty simple abstract class
public abstract class AbstractServiceActions {      @Autowired     protected DatabaseModel dbModel;      protected User user;     protected boolean complete;     protected String serviceResult;      public AbstractServiceActions(User user) {         this.user = user;         this.serviceResult = "";     }      public abstract String doAction();     }   Now you can see, I'm trying to autowire the DatabaseModel. But in my extended class I only recieve null for the dbModel.
@Component public class CreateDatabaseAction extends AbstractServiceActions { .... }   Question: Am I trying something impossible here?
We can't use @Autowired on a constructor of an abstract class. Spring doesn't evaluate the @Autowired annotation on a constructor of an abstract class. The subclass should provide the necessary arguments to the super constructor.
You don't. You only declare the beans which have a concrete subclass of that abstract class.
Annotating an interface with @Component is common for Spring classes, particularly for some Spring stereotype annotations : package org. springframework.
In an application, the business logic resides within the service layer so we use the @Service Annotation to indicate that a class belongs to that layer. It is also a specialization of @Component Annotation like the @Repository Annotation.
Your setup seems fine. The reason perhaps lies elsewhere. Maybe  you are instantiating the class with new CreateDatabaseAction(), rather than letting spring do this. 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With