我已经使用Tomcat和Postgresql RDS设置了一个Elastic Beanstalk实例。如果我在本地构建和部署,事情很好,我没有任何问题。如果我将其部署到AWS Elastic Beanstalk环境,则应用程序将无法启动,并且我在Spring ConfigurationPropertiesBindingPostProcessor.java文件中收到错误。
我的配置文件:
spring:
profiles:
active: prod
devtools:
restart:
enabled: false
livereload:
enabled: false
datasource:
driver-class-name: org.postgresql.ds.PGSimpleDataSource
url: jdbc:postgresql://arc.redacted.us-east-1.rds.amazonaws.com:5432/arc
username: redacted
password: redacted
以下是日志的相关部分:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource.CONFIGURATION_PROPERTIES': Could not bind properties to DataSourceProperties (prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is java.lang.IllegalArgumentException: Illegal group reference
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:323)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:273)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 48 more
和
Caused by: java.lang.IllegalArgumentException: Illegal group reference
at java.util.regex.Matcher.appendReplacement(Matcher.java:857)
再次,如果我部署本地,这可以正常工作。我已经确定我可以连接到RDS数据库。
其他人遇到这种情况?
答案 0 :(得分:0)
您需要添加数据库名称:
datasource:
driver-class-name: org.postgresql.ds.PGSimpleDataSource
url: jdbc:postgresql://arc.redacted.us-east-1.rds.amazonaws.com:5432/arc
name: arc
username: redacted
password: redacted