我问,因为我尝试过并且失败了。问题似乎是liquibase需要有关它正在运行的主机的信息来锁定和写入DATABASECHANGELOG。
因此,当我在ECS Fargate集群中启动我的spring-boot应用程序时,我看到了:
018-01-12 19:34:03.406 ERROR 6 --- [main] o.s.boot.SpringApplication:应用程序启动失败 org.springframework.beans.factory.BeanCreationException:创建名为' liquibase'的bean时出错在类路径资源[com / mlb / best / config / LiquibaseConfig.class]中定义:init方法的调用失败;嵌套异常是java.lang.ExceptionInInitializerError at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)~ [spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)〜[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)〜[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:306)〜[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)〜[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)〜[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)〜[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)〜[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)〜[spring-context-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)〜[spring-context-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)〜[spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE] 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)[spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE] 在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)[spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:303)[spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)[spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE] 在com.mlb.best.Application.main(Application.java:31)[classes!/:1.0-SNAPSHOT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)〜[na:1.8.0_92-internal] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[na:1.8.0_92-internal] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜[na:1.8.0_92-internal] 在java.lang.reflect.Method.invoke(Method.java:498)〜[na:1.8.0_92-internal] 在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)[application.jar:1.0-SNAPSHOT] 在org.springframework.boot.loader.Launcher.launch(Launcher.java:87)[application.jar:1.0-SNAPSHOT] 在org.springframework.boot.loader.Launcher.launch(Launcher.java:50)[application.jar:1.0-SNAPSHOT] 在org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)[application.jar:1.0-SNAPSHOT] 引起:java.lang.ExceptionInInitializerError:null at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)〜[na:1.8.0_92-internal] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)〜[na:1.8.0_92-internal] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)〜[na:1.8.0_92-internal] 在java.lang.reflect.Constructor.newInstance(Constructor.java:423)〜[na:1.8.0_92-internal] 在liquibase.sqlgenerator.SqlGeneratorFactory。(SqlGeneratorFactory.java:40)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.sqlgenerator.SqlGeneratorFactory.getInstance(SqlGeneratorFactory.java:54)〜[liquibase-core-3.3.2.jar!/:na] at liquibase.executor.AbstractExecutor.applyVisitors(AbstractExecutor.java:23)〜[liquibase-core-3.3.2.jar!/:na] at liquibase.executor.jvm.JdbcExecutor.access $ 700(JdbcExecutor.java:36)〜[liquibase-core-3.3.2.jar!/:na] at liquibase.executor.jvm.JdbcExecutor $ QueryStatementCallback.doInStatement(JdbcExecutor.java:345)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:135)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:143)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:151)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:166)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.executor.jvm.JdbcExecutor.queryForInt(JdbcExecutor.java:187)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.executor.jvm.JdbcExecutor.queryForInt(JdbcExecutor.java:182)〜[liquibase-core-3.3.2.jar!/:na] at liquibase.lockservice.StandardLockService.isDatabaseChangeLogLockTableInitialized(StandardLockService.java:118)~ [liquibase-core-3.3.2.jar!/:na] at liquibase.lockservice.StandardLockService.init(StandardLockService.java:94)〜[liquibase-core-3.3.2.jar!/:na] at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:188)~ [liquibase-core-3.3.2.jar!/:na] at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:154)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.Liquibase.update(Liquibase.java:186)〜[liquibase-core-3.3.2.jar!/:na] at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:353)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:317)〜[liquibase-core-3.3.2.jar!/:na] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)〜[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)〜[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] ...省略了23个常见帧 引起:liquibase.exception.UnexpectedLiquibaseException:java.net.UnknownHostException:19f647ae563e:19f647ae563e:未知错误 在liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator。(LockDatabaseChangeLogGenerator.java:32)〜[liquibase-core-3.3.2.jar!/:na] ...省略了48个常用帧 引起:java.net.UnknownHostException:19f647ae563e:19f647ae563e:未知错误 在java.net.InetAddress.getLocalHost(InetAddress.java:1505)〜[na:1.8.0_92-internal] at liquibase.util.NetUtil.getLocalHostName(NetUtil.java:41)〜[liquibase-core-3.3.2.jar!/:na] 在liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator。(LockDatabaseChangeLogGenerator.java:29)〜[liquibase-core-3.3.2.jar!/:na] ...省略了48个常用帧 引起:java.net.UnknownHostException:19f647ae563e:未知错误 at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)〜[na:1.8.0_92-internal] at java.net.InetAddress $ 2.lookupAllHostAddr(InetAddress.java:928)~ [na:1.8.0_92-internal] at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)〜[na:1.8.0_92-internal] at java.net.InetAddress.getLocalHost(InetAddress.java:1500)~ [na:1.8.0_92-internal] ...省略了50个常见帧
有没有办法解决这个问题,还是我必须使用AWS ECS EC2?通常我会通过检查我的/ etc / hosts来确定这一点,以确保在那里定义了localhost。但不确定我是怎么用fargate做的。
答案 0 :(得分:0)
如上所述,使用最新版本的liquibase-core解决了这个问题。