All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.wangchenning.datasource.config.DynamicRoutingDataSource Maven / Gradle / Ivy

package com.github.wangchenning.datasource.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

public class DynamicRoutingDataSource extends AbstractRoutingDataSource {



    private static Logger logger = LoggerFactory.getLogger(DynamicRoutingDataSource.class);

    @Override
    protected Object determineCurrentLookupKey() {
        String dataSourceName = DynamicDataSourceContextHolder.getDataSourceRouterKey();
        logger.info("当前数据源是:{}", dataSourceName);
        return DynamicDataSourceContextHolder.getDataSourceRouterKey();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy