I am experimenting with examples from this official Spring tutorials , and there is a dependency on this code:
https://github.com/spring-guides/gs-async-method/tree/master/complete
If you look at the code of the AppRunner.java class, I have 2 questions:
1) When the server starts, if I set a breakpoint in this class constructor, it seems like the constructor, GitHubLookupService is provided by spring using the @Service bean that was configured. BUT, there was no @Autowired annotation in the @Autowired , since in the world this constructor is called with the correct dependency? It should have been null .
Is this an automatic Spring Boot assumption?
Does Spring represent the private private + constructor argument, and does it assume that it should look for a suitable bean?
Is it Spring Framework or Spring boot ?
Did I miss something?
2) As far as I remember, it was advisable to provide a default constructor for beans / service, etc. How does this class (AppRunner) not have a default constructor? How does Spring know that it should run the constructor with an argument? Is it because it's the only constructor?
spring spring-boot dependency-injection autowired
winter
source share