java.sql.SQLException 从 spring boot 2.6.7 升级到 2.7.0 后
java.sql.SQLException after upgrading from spring boot 2.6.7 to 2.7.0
我们正在将我们的应用程序从 spring 引导版本 2.6.7 升级到 2.7.0,我们开始在应用程序启动时遇到错误:
java.sql.SQLException: Identity plugin 'AWS-IAM' is used without having AWS SDK in classpath. Please add 'software.amazon.awssdk:rds' to classpath
我们已经添加了以下依赖项:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-rds</artifactId>
<version>1.12.221</version>
</dependency>
没有对代码进行其他更改。关于如何解决这个问题有什么想法吗?
堆栈跟踪:
java.sql.SQLException: Identity plugin 'AWS-IAM' is used without having AWS SDK in classpath. Please add 'software.amazon.awssdk:rds' to classpath
at org.mariadb.jdbc.plugin.credential.aws.AwsIamCredentialPlugin.initialize(AwsIamCredentialPlugin.java:58)
at org.mariadb.jdbc.client.impl.ConnectionHelper.loadCredential(ConnectionHelper.java:340)
at org.mariadb.jdbc.client.impl.StandardClient.<init>(StandardClient.java:175)
at org.mariadb.jdbc.Driver.connect(Driver.java:64)
at org.mariadb.jdbc.Driver.connect(Driver.java:83)
at org.mariadb.jdbc.Driver.connect(Driver.java:27)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:266)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=13=](AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
Spring Boot 2.7 已从 mariadb-java-client
的 2.7.x 升级到 3.0.x。在3.0.x中,他们对AwsIamCredentialPlugin
做了一些修改。以前,它会查找 com.amazonaws.auth.BasicAWSCredentials
的存在,但现在它会查找位于不同模块中的 software.amazon.awssdk.auth.credentials.AwsBasicCredentials
。
如异常消息所示,添加对 software.amazon.awssdk:rds
的依赖应该可以解决问题。 2.17.199 是撰写本文时的最新版本:
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>rds</artifactId>
<version>2.17.199</version>
</dependency>
我们正在将我们的应用程序从 spring 引导版本 2.6.7 升级到 2.7.0,我们开始在应用程序启动时遇到错误:
java.sql.SQLException: Identity plugin 'AWS-IAM' is used without having AWS SDK in classpath. Please add 'software.amazon.awssdk:rds' to classpath
我们已经添加了以下依赖项:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-rds</artifactId>
<version>1.12.221</version>
</dependency>
没有对代码进行其他更改。关于如何解决这个问题有什么想法吗?
堆栈跟踪:
java.sql.SQLException: Identity plugin 'AWS-IAM' is used without having AWS SDK in classpath. Please add 'software.amazon.awssdk:rds' to classpath
at org.mariadb.jdbc.plugin.credential.aws.AwsIamCredentialPlugin.initialize(AwsIamCredentialPlugin.java:58)
at org.mariadb.jdbc.client.impl.ConnectionHelper.loadCredential(ConnectionHelper.java:340)
at org.mariadb.jdbc.client.impl.StandardClient.<init>(StandardClient.java:175)
at org.mariadb.jdbc.Driver.connect(Driver.java:64)
at org.mariadb.jdbc.Driver.connect(Driver.java:83)
at org.mariadb.jdbc.Driver.connect(Driver.java:27)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:266)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=13=](AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
Spring Boot 2.7 已从 mariadb-java-client
的 2.7.x 升级到 3.0.x。在3.0.x中,他们对AwsIamCredentialPlugin
做了一些修改。以前,它会查找 com.amazonaws.auth.BasicAWSCredentials
的存在,但现在它会查找位于不同模块中的 software.amazon.awssdk.auth.credentials.AwsBasicCredentials
。
如异常消息所示,添加对 software.amazon.awssdk:rds
的依赖应该可以解决问题。 2.17.199 是撰写本文时的最新版本:
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>rds</artifactId>
<version>2.17.199</version>
</dependency>