0
 @Autowired
private AuthenticationManager authenticationManager;

I have this line in my project and after my understanding of @autowired, there must be some of bean dependency injection. But I cannot see any spring boot bean configuration file as mentioned online. So I am confused about what this statement will do. I am completely new to java

nitin
  • 80
  • 4
  • 14
  • 1
    Does this answer your question? [Understanding Spring @Autowired usage](https://stackoverflow.com/questions/19414734/understanding-spring-autowired-usage) – andrewJames May 09 '20 at 17:24
  • 1
    In Spring Boot, a bean configuration file is not required. It is maintained internally. `Autowired` annotation does work behind the scene – Nitin Bisht May 09 '20 at 17:27
  • 1
    Check https://medium.com/doku-insight/meaning-of-autowired-in-spring-boot-214b623d5ddb for detailed understanding – Nitin Bisht May 09 '20 at 17:29
  • 1
    The Bean can be injected only when someone asks Spring to create it. There are 2 ways to create it.... one by Spring XML context and another by Annotations... check if your project has Component. I would not worry about Autowired... rather search for implementations of "AuthenticationManager" in your classpath... that should lead somewhere. Also if the Bean is not found at Runtime then the dependent Bean (Your Bean in this case) will not be created and the Spring container will crash. So run-it ... you will know more. – A G May 09 '20 at 17:48
  • @NitinBisht in the medium article there is a method named dependencyInjectionSetter is there any such method also for above and if yes then where its and will it initialise it by default values? – nitin May 09 '20 at 19:10
  • @nitin no we don't have any such method. It was an example for clarity only. – Nitin Bisht May 09 '20 at 19:31
  • @nitin does your project have `@EnableWebSecurity` or `AuthenticationManagerBuilder` in any class? – Madhu Bhat May 10 '20 at 06:40
  • @MadhuBhat yes i have AuthenticationManagerBuilder and also EnableWebSecurity – nitin May 10 '20 at 20:24
  • @nitin can you add the code snippet here regarding `AuthenticationManagerBuilder` that you have? – Madhu Bhat May 11 '20 at 05:42

0 Answers0