在开发环境本地运行正常,发布到测试环境报错
Factory method 'magicDynamicDataSource' threw exception; nested exception is cn.hutool.crypto.CryptoException: SecurityException: JCE cannot authenticate the provider BC
对比开发环境和测试环境,开发、测试环境都使用JDK17。开发环境在JDK8正常,切换到JDK17测试。JDK17下,用java -jar运行正常,但服务方式运行报错。
网上搜解决方案,需要修改JDK的配置。但每次新的部署都去修改JDK配置,很麻烦也容易遗漏。
参考 https://www.lsjlt.com/news/389168.html,在程序调用前执行 GlobalBouncyCastleProvider.setUseBouncyCastle(false);