I am following a YouTube tutorial to build a spring boot application. The person used lombok and so he didn't had the @Autowired
annotation on any field of the class and his code works fine. However when I tried the same, the console shows the service is null.
Appropriate code and Output Screenshot attached for reference.
@AllArgsConstructor
public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
private AppUserService appUserService;
private BCryptPasswordEncoder bCryptpasswordEncoder;
@Bean
public DaoAuthenticationProvider daoAuthenticationProvider() {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(appUserService);
provider.setPasswordEncoder(bCryptpasswordEncoder);
return provider;
}
}
On removing the @AllArgsConstructor
, and using the @Autowired
annotation my code works.
So, Does using lombok dependency with spring boot auto wires the fields automatically? if yes then what mistake am I doing?
PS : I am using Java 11 with Spring boot 2.4.5 on STS 4