<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>For English only</strong>, other languages will not accept.</p>
<p dir="auto">Before report a bug, make sure you have:</p>
<ul dir="auto">
<li>Searched open and closed <a href="https://github.com/apache/shardingsphere/issues">GitHub issues</a>.</li>
<li>Read documentation: <a href="https://shardingsphere.apache.org/document/current/en/overview" rel="nofollow">ShardingSphere Doc</a>.</li>
</ul>
<p dir="auto">Please pay attention on issues you submitted, because we maybe need more details.<br>
If no response anymore and we cannot reproduce it on current information, we will <strong>close it</strong>.</p>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<p dir="auto">5.0.0-RC1-SNAPSHOT</p>
<h3 dir="auto">Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?</h3>
<p dir="auto">ShardingSphere-Proxy</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">CREATE TABLE executed correctly.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">Either</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mysql&gt; CREATE TABLE `t_encrypt` (  `user_id` bigint DEFAULT NULL,  `order_id` bigint DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
ERROR 19999 (C1999): 9Unknown exception: [null]"><pre class="notranslate"><code class="notranslate">mysql&gt; CREATE TABLE `t_encrypt` (  `user_id` bigint DEFAULT NULL,  `order_id` bigint DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
ERROR 19999 (C1999): 9Unknown exception: [null]
</code></pre></div>
<p dir="auto">or</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mysql&gt; CREATE TABLE `t_encrypt` (
    -&gt;   `user_id` bigint DEFAULT NULL,
    -&gt;   `order_id` bigint DEFAULT NULL,
    -&gt;   `user_cipher` varchar(100) DEFAULT NULL,
    -&gt;   `order_cipher` varchar(100) DEFAULT NULL
    -&gt; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
ERROR 19999 (C1999): 9Unknown exception: [null]"><pre class="notranslate"><code class="notranslate">mysql&gt; CREATE TABLE `t_encrypt` (
    -&gt;   `user_id` bigint DEFAULT NULL,
    -&gt;   `order_id` bigint DEFAULT NULL,
    -&gt;   `user_cipher` varchar(100) DEFAULT NULL,
    -&gt;   `order_cipher` varchar(100) DEFAULT NULL
    -&gt; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
ERROR 19999 (C1999): 9Unknown exception: [null]
</code></pre></div>
<h3 dir="auto">Reason analyze (If you can)</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[INFO ] 2021-03-03 18:23:47.852 [ShardingSphere-Command-2] ShardingSphere-SQL - Logic SQL: CREATE TABLE `t_encrypt` (  `user_id` bigint DEFAULT NULL,  `order_id` bigint DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
[INFO ] 2021-03-03 18:23:47.852 [ShardingSphere-Command-2] ShardingSphere-SQL - SQLStatement: MySQLCreateTableStatement(isNotExisted=false)
[INFO ] 2021-03-03 18:23:47.852 [ShardingSphere-Command-2] ShardingSphere-SQL - Actual SQL: dataSource ::: CREATE TABLE `t_encrypt` (  `user_id` bigint DEFAULT NULL,  `order_id` bigint DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
[ERROR] 2021-03-03 18:23:47.914 [ShardingSphere-Command-2] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
java.util.NoSuchElementException: null
	at java.util.ArrayList$Itr.next(ArrayList.java:862)
	at org.apache.shardingsphere.infra.metadata.schema.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:50)
	at org.apache.shardingsphere.infra.metadata.schema.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:37)
	at org.apache.shardingsphere.infra.metadata.engine.MetadataRefreshEngine.refreshSchema(MetadataRefreshEngine.java:75)
	at org.apache.shardingsphere.infra.metadata.engine.MetadataRefreshEngine.refresh(MetadataRefreshEngine.java:64)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.refreshMetadata(DatabaseCommunicationEngine.java:190)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:113)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:101)
	at org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:57)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)"><pre class="notranslate"><code class="notranslate">[INFO ] 2021-03-03 18:23:47.852 [ShardingSphere-Command-2] ShardingSphere-SQL - Logic SQL: CREATE TABLE `t_encrypt` (  `user_id` bigint DEFAULT NULL,  `order_id` bigint DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
[INFO ] 2021-03-03 18:23:47.852 [ShardingSphere-Command-2] ShardingSphere-SQL - SQLStatement: MySQLCreateTableStatement(isNotExisted=false)
[INFO ] 2021-03-03 18:23:47.852 [ShardingSphere-Command-2] ShardingSphere-SQL - Actual SQL: dataSource ::: CREATE TABLE `t_encrypt` (  `user_id` bigint DEFAULT NULL,  `order_id` bigint DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
[ERROR] 2021-03-03 18:23:47.914 [ShardingSphere-Command-2] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
java.util.NoSuchElementException: null
	at java.util.ArrayList$Itr.next(ArrayList.java:862)
	at org.apache.shardingsphere.infra.metadata.schema.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:50)
	at org.apache.shardingsphere.infra.metadata.schema.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:37)
	at org.apache.shardingsphere.infra.metadata.engine.MetadataRefreshEngine.refreshSchema(MetadataRefreshEngine.java:75)
	at org.apache.shardingsphere.infra.metadata.engine.MetadataRefreshEngine.refresh(MetadataRefreshEngine.java:64)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.refreshMetadata(DatabaseCommunicationEngine.java:190)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:113)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:101)
	at org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:57)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
</code></pre></div>
<p dir="auto">And</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[INFO ] 2021-03-03 18:13:11.271 [ShardingSphere-Command-1] ShardingSphere-SQL - Logic SQL: CREATE TABLE `t_encrypt` (
  `user_id` bigint DEFAULT NULL,
  `order_id` bigint DEFAULT NULL,
  `user_cipher` varchar(100) DEFAULT NULL,
  `order_cipher` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
[INFO ] 2021-03-03 18:13:11.271 [ShardingSphere-Command-1] ShardingSphere-SQL - SQLStatement: MySQLCreateTableStatement(isNotExisted=false)
[INFO ] 2021-03-03 18:13:11.271 [ShardingSphere-Command-1] ShardingSphere-SQL - Actual SQL: dataSource ::: CREATE TABLE `t_encrypt` (
  `user_id` bigint DEFAULT NULL,
  `order_id` bigint DEFAULT NULL,
  `user_cipher` varchar(100) DEFAULT NULL,
  `order_cipher` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
[ERROR] 2021-03-03 18:13:11.383 [ShardingSphere-Command-1] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
java.util.NoSuchElementException: null
	at java.util.ArrayList$Itr.next(ArrayList.java:862)
	at org.apache.shardingsphere.infra.metadata.schema.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:50)
	at org.apache.shardingsphere.infra.metadata.schema.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:37)
	at org.apache.shardingsphere.infra.metadata.engine.MetadataRefreshEngine.refreshSchema(MetadataRefreshEngine.java:75)
	at org.apache.shardingsphere.infra.metadata.engine.MetadataRefreshEngine.refresh(MetadataRefreshEngine.java:64)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.refreshMetadata(DatabaseCommunicationEngine.java:190)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:113)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:101)
	at org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:57)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)"><pre class="notranslate"><code class="notranslate">[INFO ] 2021-03-03 18:13:11.271 [ShardingSphere-Command-1] ShardingSphere-SQL - Logic SQL: CREATE TABLE `t_encrypt` (
  `user_id` bigint DEFAULT NULL,
  `order_id` bigint DEFAULT NULL,
  `user_cipher` varchar(100) DEFAULT NULL,
  `order_cipher` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
[INFO ] 2021-03-03 18:13:11.271 [ShardingSphere-Command-1] ShardingSphere-SQL - SQLStatement: MySQLCreateTableStatement(isNotExisted=false)
[INFO ] 2021-03-03 18:13:11.271 [ShardingSphere-Command-1] ShardingSphere-SQL - Actual SQL: dataSource ::: CREATE TABLE `t_encrypt` (
  `user_id` bigint DEFAULT NULL,
  `order_id` bigint DEFAULT NULL,
  `user_cipher` varchar(100) DEFAULT NULL,
  `order_cipher` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
[ERROR] 2021-03-03 18:13:11.383 [ShardingSphere-Command-1] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
java.util.NoSuchElementException: null
	at java.util.ArrayList$Itr.next(ArrayList.java:862)
	at org.apache.shardingsphere.infra.metadata.schema.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:50)
	at org.apache.shardingsphere.infra.metadata.schema.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:37)
	at org.apache.shardingsphere.infra.metadata.engine.MetadataRefreshEngine.refreshSchema(MetadataRefreshEngine.java:75)
	at org.apache.shardingsphere.infra.metadata.engine.MetadataRefreshEngine.refresh(MetadataRefreshEngine.java:64)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.refreshMetadata(DatabaseCommunicationEngine.java:190)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:113)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:101)
	at org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:57)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
</code></pre></div>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<p dir="auto">config-encrypt.yaml</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="schemaName: encrypt_db

dataSource:
  url: jdbc:mysql://127.0.0.1:3306/demo_ds?serverTimezone=UTC&amp;useSSL=false
  username: root
  password:
  connectionTimeoutMilliseconds: 30000
  idleTimeoutMilliseconds: 60000
  maxLifetimeMilliseconds: 1800000
  maxPoolSize: 50

rules:
- !ENCRYPT
  encryptors:
    aes_encryptor:
      type: AES
      props:
        aes-key-value: 123456abc
    md5_encryptor:
      type: MD5
  tables:
    t_encrypt:
      columns:
        user_id:
          cipherColumn: user_cipher
          encryptorName: md5_encryptor
        order_id:
          cipherColumn: order_cipher
          encryptorName: md5_encryptor"><pre class="notranslate"><code class="notranslate">schemaName: encrypt_db

dataSource:
  url: jdbc:mysql://127.0.0.1:3306/demo_ds?serverTimezone=UTC&amp;useSSL=false
  username: root
  password:
  connectionTimeoutMilliseconds: 30000
  idleTimeoutMilliseconds: 60000
  maxLifetimeMilliseconds: 1800000
  maxPoolSize: 50

rules:
- !ENCRYPT
  encryptors:
    aes_encryptor:
      type: AES
      props:
        aes-key-value: 123456abc
    md5_encryptor:
      type: MD5
  tables:
    t_encrypt:
      columns:
        user_id:
          cipherColumn: user_cipher
          encryptorName: md5_encryptor
        order_id:
          cipherColumn: order_cipher
          encryptorName: md5_encryptor
</code></pre></div>
<p dir="auto">server.yaml</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="authentication:
  users:
    root:
      password: root
      hostname: '%'
    sharding:
      password: sharding

props:
  max-connections-size-per-query: 1
  executor-size: 16  # Infinite by default.
  proxy-frontend-flush-threshold: 128  # The default value is 128.
    # LOCAL: Proxy will run with LOCAL transaction.
    # XA: Proxy will run with XA transaction.
    # BASE: Proxy will run with B.A.S.E transaction.
  proxy-transaction-type: LOCAL
  xa-transaction-manager-type: Atomikos
  proxy-opentracing-enabled: false
  proxy-hint-enabled: false
  query-with-cipher-column: true
  sql-show: true
  check-table-metadata-enabled: false
  lock-wait-timeout-milliseconds: 50000 # The maximum time to wait for a lock"><pre class="notranslate"><code class="notranslate">authentication:
  users:
    root:
      password: root
      hostname: '%'
    sharding:
      password: sharding

props:
  max-connections-size-per-query: 1
  executor-size: 16  # Infinite by default.
  proxy-frontend-flush-threshold: 128  # The default value is 128.
    # LOCAL: Proxy will run with LOCAL transaction.
    # XA: Proxy will run with XA transaction.
    # BASE: Proxy will run with B.A.S.E transaction.
  proxy-transaction-type: LOCAL
  xa-transaction-manager-type: Atomikos
  proxy-opentracing-enabled: false
  proxy-hint-enabled: false
  query-with-cipher-column: true
  sql-show: true
  check-table-metadata-enabled: false
  lock-wait-timeout-milliseconds: 50000 # The maximum time to wait for a lock
</code></pre></div>
<h3 dir="auto">Example codes for reproduce this issue (such as a github link).</h3>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!<br>
使用DataSourceUtil的编程方式连接数据源</p>
<p dir="auto">`<br>
<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/configuration/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/configuration">@configuration</a><br>
@MapperScan("com.knowbox.kms.tiku.dao")<br>
public class MyBatisConfig {</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="private static final String URL_PREFIX = &quot;jdbc:mysql://127.0.0.1:3306/&quot;;

private static final String USER_NAME = &quot;test&quot;;

private static final String PASSWORD = &quot;test&quot;;

@Bean
@Primary
public static SqlSessionFactoryBean createSqlSessionFactoryBean() throws SQLException, IOException {

    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    // 设置mybatis configuration 扫描路径
    sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(&quot;META-INF/mybatis-config.xml&quot;));

    // 添加mapper 扫描路径
    PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(pathMatchingResourcePatternResolver.getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + &quot;/META-INF/mapper/*.xml&quot;));

    // 设置datasource
    DataSource dataSource = getMasterSlaveDataSource();
    sqlSessionFactoryBean.setDataSource(dataSource);
    return sqlSessionFactoryBean;
}

private static DataSource getMasterSlaveDataSource() throws SQLException {
    MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration();
    masterSlaveRuleConfig.setName(&quot;ds_master_slave&quot;);
    masterSlaveRuleConfig.setMasterDataSourceName(&quot;ds_master&quot;);
    masterSlaveRuleConfig.setSlaveDataSourceNames(Arrays.asList(&quot;ds_slave_0&quot;, &quot;ds_slave_1&quot;));
    return MasterSlaveDataSourceFactory.createDataSource(createDataSourceMap(), masterSlaveRuleConfig, new ConcurrentHashMap&lt;&gt;());
}

private static Map&lt;String, DataSource&gt; createDataSourceMap() {
    final Map&lt;String, DataSource&gt; result = new HashMap&lt;&gt;(3, 1);
    result.put(&quot;ds_master&quot;, createDataSource(&quot;dev&quot;));
    result.put(&quot;ds_slave_0&quot;, createDataSource(&quot;dev&quot;));
    result.put(&quot;ds_slave_1&quot;, createDataSource(&quot;dev&quot;));
    return result;
}

private static DataSource createDataSource(final String dataSourceName) {

    DruidDataSource result = new DruidDataSource();
    result.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
    result.setUrl(URL_PREFIX + dataSourceName);
    result.setUsername(USER_NAME);
    result.setPassword(PASSWORD);
    return result;
}"><pre class="notranslate"><code class="notranslate">private static final String URL_PREFIX = "jdbc:mysql://127.0.0.1:3306/";

private static final String USER_NAME = "test";

private static final String PASSWORD = "test";

@Bean
@Primary
public static SqlSessionFactoryBean createSqlSessionFactoryBean() throws SQLException, IOException {

    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    // 设置mybatis configuration 扫描路径
    sqlSessionFactoryBean.setConfigLocation(new ClassPathResource("META-INF/mybatis-config.xml"));

    // 添加mapper 扫描路径
    PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(pathMatchingResourcePatternResolver.getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "/META-INF/mapper/*.xml"));

    // 设置datasource
    DataSource dataSource = getMasterSlaveDataSource();
    sqlSessionFactoryBean.setDataSource(dataSource);
    return sqlSessionFactoryBean;
}

private static DataSource getMasterSlaveDataSource() throws SQLException {
    MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration();
    masterSlaveRuleConfig.setName("ds_master_slave");
    masterSlaveRuleConfig.setMasterDataSourceName("ds_master");
    masterSlaveRuleConfig.setSlaveDataSourceNames(Arrays.asList("ds_slave_0", "ds_slave_1"));
    return MasterSlaveDataSourceFactory.createDataSource(createDataSourceMap(), masterSlaveRuleConfig, new ConcurrentHashMap&lt;&gt;());
}

private static Map&lt;String, DataSource&gt; createDataSourceMap() {
    final Map&lt;String, DataSource&gt; result = new HashMap&lt;&gt;(3, 1);
    result.put("ds_master", createDataSource("dev"));
    result.put("ds_slave_0", createDataSource("dev"));
    result.put("ds_slave_1", createDataSource("dev"));
    return result;
}

private static DataSource createDataSource(final String dataSourceName) {

    DruidDataSource result = new DruidDataSource();
    result.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
    result.setUrl(URL_PREFIX + dataSourceName);
    result.setUsername(USER_NAME);
    result.setPassword(PASSWORD);
    return result;
}
</code></pre></div>
<p dir="auto">`</p>
<h3 dir="auto">Which version of Sharding-Jdbc do you using?（您使用的Sharding-Jdbc版本为？）</h3>
<p dir="auto">sharing jdbc 2.0.3<br>
druid 1.1.9</p>
<h3 dir="auto">Expected behavior （您预期的结果是）</h3>
<h3 dir="auto">Actual behavior （实际运行的结果是）</h3>
<p dir="auto">Caused by: java.lang.NullPointerException: null<br>
at io.shardingjdbc.spring.boot.SpringBootConfiguration.setDataSourceMap(SpringBootConfiguration.java:55) ~[sharding-jdbc-core-spring-boot-starter-2.0.3.jar:na]<br>
at io.shardingjdbc.spring.boot.SpringBootConfiguration.setEnvironment(SpringBootConfiguration.java:49) ~[sharding-jdbc-core-spring-boot-starter-2.0.3.jar:na]<br>
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]<br>
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:97) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]<br>
... 15 common frames omitted</p>