我目前正在一个项目中,我们的应用程序需要在该项目中连接到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
我不确定为什么上面的设置看起来不错时,它告诉我密码为空。
任何建议都会有所帮助。让我知道是否需要提供其他服务。
谢谢。
答案 0 :(得分:3)
我遇到了同样的问题。我的配置与您的配置类似:
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 boot应用程序能够启动。