spring.datasource.tomcat.jdbc-interceptors=com.demo.YourInterceptor;ConnectionState(这个是自带的拦截器)
public class YourInterceptor extends JdbcInterceptor { @Override public void reset(ConnectionPool connectionPool, PooledConnection pooledConnection) { try { //切库 pooledConnection.getConnection().setCatalog(databaseName); } catch (SQLException e) { LOGGER.error("tenant change error: {}", e); } }}