Spring Security circular bean dependency

后端 未结 5 1389
梦毁少年i
梦毁少年i 2020-12-13 14:25

I\'m currently working on a Vaadin spring application. According to the app specifications, authentication/authorization of the users must be completed by querying database

5条回答
  •  情书的邮戳
    2020-12-13 14:26

    One of the solution is don't use constructor. For exaple instead of:

    private final JdbcTemplate jdbcTemplate;
    private final PasswordEncoder passwordEncoder;
    
    @Autowired
    public JdbcAccountRepository(JdbcTemplate jdbcTemplate, PasswordEncoder passwordEncoder) {
        this.jdbcTemplate = jdbcTemplate;
        this.passwordEncoder = passwordEncoder;
    }
    

    You can use:

    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PasswordEncoder passwordEncoder;
    

提交回复
热议问题