免费做网站怎么做网站,app发布流程,自己做的个人网站无法备案,做网站建设网站制作场景 
近日一个项目使用了shardingsphere后出现 java.lang.UnsupportedOperationException: Cannot support database type MySQL , 
重点是在dev-pre环境中无法出现这个问题#xff0c;而是在prod环境中会发生#xff0c;且prod也不是100%发生#xff0c; 
当流量过大时会发…场景 
近日一个项目使用了shardingsphere后出现 java.lang.UnsupportedOperationException: Cannot support database type MySQL , 
重点是在dev-pre环境中无法出现这个问题而是在prod环境中会发生且prod也不是100%发生 
当流量过大时会发生这个问题这个项目之前没有引入查询DB的操作近日因为需求引入了DB查询前同事写代码随便乱入各种多线程虽然最终问题得以解决还是因为怀疑乱用多线程导致。 
解决方法 
Spring Boot项目在 main 方法启动时增加一个 NewInstanceServiceLoader.register(SQLParserConfiguration.class); 
SpringBootApplication
EnableAsync
EnableScheduling
MapperScan(basePackages  {XXXXXXX})
EnableAutoConfiguration(exclude  {ElasticsearchAutoConfiguration.class, RestClientAutoConfiguration.class})
public class StartEngine {
public static void main(String[] args) {NewInstanceServiceLoader.register(SQLParserConfiguration.class);SpringApplication.run(StartEngine.class, args);
}
}非spring boot项目使用 
component
slf4j
public class ApplicationStartedListener implements ApplicationListener {
OverRide
public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
onApplicationStarted(applicationStartedEvent);
}SneakyThrows
private void onApplicationStarted(ApplicationStartedEvent event) {String applicationName  event.getApplicationContext().getApplicationName();log.info(应用【{}】已启动...., applicationName);NewInstanceServiceLoader.register(SQLParserConfiguration.class);log.info(已加载{}, SQLParserConfiguration);
}
}总之加上 NewInstanceServiceLoader.register(SQLParserConfiguration.class);  这个就对了。 
主要参考这两个issues 
https://github.com/apache/shardingsphere/issues/7701https://github.com/apache/shardingsphere/issues/7947 
这里还提到了使用多线程API parallelStream 也会导致这个问题等等。