Answer the question
In order to leave comments, you need to log in
Why is there a cyclical addiction?
Good evening.
I am making a REST API based on the following tutorial
https://habr.com/en/post/482552/
And for some reason a cyclic dependency appeared
Specifically, this moment was made exactly as in the article
I tried to add the Lazy annotation, it gives an error
Here is a link to the git,
Help please sort out the reasons
https://gitlab.com/alkella99/notes_api/-/tree/master
Answer the question
In order to leave comments, you need to log in
@Configuration
public class AppConfig {
@Autowired
@Lazy
UserService userService;
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder(5);
}
@Autowired
protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService).passwordEncoder(bCryptPasswordEncoder());
}
}
@Autowired
protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService).passwordEncoder(bCryptPasswordEncoder());
}
- there is some kind of abracadabra here. What does void do in config? Why is he throwing an exception? ...
@Autowired
AuthenticationManagerBuilder auth;
@PostConstruct
void init() {
auth.userDetailsService(this).passwordEncoder(bCryptPasswordEncoder);
}
...
I solved it all by specifying in application.properties:
spring.main.allow-circular-references: true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question