在尝试运行maven测试时遇到此问题。不确定是什么原因导致了问题,因为这些测试以前运行时没有出现问题。我的依赖关系由maven 管理
Caused by: java.lang.NoClassDefFoundError: Could not initialize class liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator
at sun.reflect.GeneratedConstructorAccessor379.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at liquibase.sqlgenerator.SqlGeneratorFactory.<init>(SqlGeneratorFactory.java:39)
at liquibase.sqlgenerator.SqlGeneratorFactory.getInstance(SqlGeneratorFactory.java:53)
at liquibase.executor.AbstractExecutor.applyVisitors(AbstractExecutor.java:22)
at liquibase.executor.jvm.JdbcExecutor.access$500(JdbcExecutor.java:35)
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:284)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:54)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:106)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:96)
at liquibase.lockservice.StandardLockService.init(StandardLockService.java:83)
at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:182)
at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:148)
at liquibase.Liquibase.update(Liquibase.java:189)
at liquibase.Liquibase.update(Liquibase.java:181)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:342)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:299)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
在OSX:上测试的快速修复程序
在控制台中键入:
$ hostname -f
输出应该有点像这样:
MAC008.local
将其作为本地主机添加到您的主机文件中:
$ sudo vi /etc/hosts
看起来有点像这样:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 MAC008.local
一旦你改变了你的人际网络,重复这个步骤。
从Windows切换到Linux后,我也遇到了同样的问题。我发现了模拟错误https://liquibase.jira.com/browse/CORE-1943我配置了nss-myhostname,这个错误就消失了。