Error when injecting Service within a @Component

Asked

Viewed 91 times

0

Set an example bean:

@Component
public class SimulationModelFactory {

and within the class I am injecting my service example:

@Autowired
private SimulationFlowService simulationFlowService;

Service always stays null

1 answer

0


The annotation @Autowired will try to inject some class that implements the interface SimulationFlowService (or the classes themselves).

Note that your class SimulationModelFactory is neither. Try to write down @Component in a class that implements the interface.

  • Simulationflowservice is not an interface is a service.

  • Right, but he’s different from SimulationModelFactory. Write him down with @Component.

  • It worked! thank you very much but I still don’t understand very well why it didn’t work with @service.

  • @Josevieiraneto, if it was noted with @Service should work smoothly. If you’re sure it was just this change, I can’t explain it to you =).

  • that’s all I’ve changed :|

  • Check your configuration. No stackoverflow.with in English has a similar problem to your.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.