我正在尝试将应用程序部署到AWS Elastic Beanstalk
并陷入数据库连接问题。
我已经创建了DB Instance
,DB Cluster
,并且已经像这样设置了Environment's variable
。
这是我的application.yml
datasources:
default:
url: ${JDBC_URL:`jdbc:mysql://localhost:3306/test_authentication?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false`}
username: ${JDBC_USER:root}
password: ${JDBC_PASSWORD:root}
driverClassName: ${JDBC_DRIVER:com.mysql.jdbc.Driver}
我确定我的数据库存在。
这是我最新的日志。
at io.micronaut.context.BeanDefinitionDelegate.build(BeanDefinitionDelegate.java:194)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1329)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1902)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1623)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1603)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:896)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:973)
at io.micronaut.configuration.hibernate.jpa.$EntityManagerFactoryBean$HibernateSessionFactoryBuilderDefinition.build(Unknown Source)
at io.micronaut.context.BeanDefinitionDelegate.build(BeanDefinitionDelegate.java:197)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1329)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1902)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1623)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1603)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:896)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:973)
at io.micronaut.configuration.hibernate.jpa.$EntityManagerFactoryBean$HibernateSessionFactoryDefinition.build(Unknown Source)
at io.micronaut.context.BeanDefinitionDelegate.build(BeanDefinitionDelegate.java:197)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1329)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1902)
at io.micronaut.context.DefaultBeanContext.loadContextScopeBean(DefaultBeanContext.java:1533)
at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1049)
... 8 common frames omitted
Caused by: io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type [org.hibernate.boot.registry.StandardServiceRegistry]
Message: Failed to initialize pool: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Path Taken: SessionFactory.hibernateSessionFactory([SessionFactoryBuilder sessionFactoryBuilder]) --> SessionFactoryBuilder.hibernateSessionFactoryBuilder([MetadataSources metadataSources],ValidatorFactory validatorFactory) --> MetadataSources.hibernateMetadataSources(JpaConfiguration jpaConfiguration,[StandardServiceRegistry standardServiceRegistry]) --> StandardServiceRegistry.hibernateStandardServiceRegistry(String dataSourceName,[DataSource dataSource])
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1343)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:1902)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1623)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1603)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:896)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:973)
... 40 common frames omitted
Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not create connection to database server. Attempted reconnect 3 times. Giving up.