cloud.aws.jdbc.datasource Throwing Assertion Error: Password Must Not Be Null for Spring Boot App

cloud.aws.jdbc.datasource Throwing Assertion Error: Password Must Not Be Null for Spring Boot App

我目前正在处理一个项目,其中我们的应用程序需要连接到 Amazon RDS 实例。到目前为止,我一直在使用以下文档进行设置: https://cloud.spring.io/spring-cloud-aws/spring-cloud-aws.html#_sdk_credentials_configuration

根据文档第 7.3 节,我应该这样设置我的 application.properties 文件:

cloud.aws.credentials.accessKey=XXXXXXXXXXXXXXX
cloud.aws.credentials.secretKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
cloud.aws.credentials.instanceProfile=true

cloud.aws.region.static=us-east-2

cloud.aws.rds.instanceNameTest
cloud.aws.rds.instanceNameTest.password=chownTestPW
cloud.aws.rds.instanceNameTest.username=dataTest1
cloud.aws.rds.instanceNameTest.databaseName=testDB

但是,当我运行申请时,我收到以下错误:

Caused by: java.lang.IllegalArgumentException: Password must not be null
at org.springframework.util.Assert.notNull(Assert.java:193) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.cloud.aws.jdbc.datasource.DataSourceInformation.<init>(DataSourceInformation.java:65) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.fromRdsInstance(AmazonRdsDataSourceFactoryBean.java:187) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createDataSourceInstance(AmazonRdsDataSourceFactoryBean.java:153) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:130) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:45) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:141) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1765) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 30 common frames omitted

我不确定为什么上面的设置看起来没问题,但它告诉我密码为空。

任何建议都会有所帮助。如果我需要提供其他任何东西,请告诉我。

谢谢。

我运行陷入同样的​​问题。我的配置与您的类似:

cloud.aws.rds.springdemo
cloud.aws.rds.springdemo.databaseName=springdemo
cloud.aws.rds.springdemo.username=springdemo
cloud.aws.rds.springdemo.password=Everyday123

我通过删除 属性 cloud.aws.rds.springdemo 解决了问题,因此只有

cloud.aws.rds.springdemo.databaseName=springdemo
cloud.aws.rds.springdemo.username=springdemo
cloud.aws.rds.springdemo.password=Everyday123

留了下来。在那之后,我没有收到任何断言错误,我的 spring 启动应用程序能够启动。