How to add a client using JDBC for ClientDetailsServiceConfigurer in Spring?

后端 未结 5 1535
迷失自我
迷失自我 2021-01-30 09:58

I have the in memory thing working as follows:

@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {

        clients.inMemo         


        
5条回答
  •  生来不讨喜
    2021-01-30 10:12

    Adding my two cents.

    If you are initializing db structures on startup (with dropping previous), for example like this:

    @Bean
    public DataSourceInitializer dataSourceInitializer(DataSource dataSource) {
        //...setting dataSource and databasePopulator
    }
    private DatabasePopulator databasePopulator() {
        //...adding your schema script
    }
    @Bean
    public DataSource dataSource() {
        //...setting driverclassname, url, etc
    }
    
    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        //...
        clients.jdbc(this.dataSource()).withClient("example").(...).build()
    }
    

    beware.

    Beans does not have to be created in some specific order, so you may catch situation when you insert lines in your old tables, and then replacing it with new, from your schema. So, you may wonder for a while, why is it still not inserting lines. I hope, this would help someone.

提交回复
热议问题