Comments (7)
Hi, what version of embedded database do you use? Because since version 1.3.0, Spring Boot 2 and Flyway 5 should be supported. Here is a demo project that uses them and works well.
from embedded-database-spring-test.
I was on 1.2.0
. I looked in mvnrepository.com for the latest version and saw 1.2.0
is the latest for embedded-database-spring-test-core
so figured that's the latest - I see embedded-database-spring-test
is at 1.3.0
. After your question I played around a bit and now my tests are working great.
I'm not sure if this is expected or not, but I have to list the following two dependencies or my tests won't run on Flyway 4.x:
<dependency>
<groupId>io.zonky.test</groupId>
<artifactId>embedded-database-spring-test</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>io.zonky.test</groupId>
<artifactId>embedded-database-spring-test-core</artifactId>
<version>1.2.0</version>
</dependency>
Omitting embedded-database-spring-test-core
leads to this:
Caused by: java.lang.ClassNotFoundException: io.zonky.test.db.postgres.EmbeddedPostgresContextCustomizerFactory
Putting it back, Flyway 4.x works. However, I still cannot run tests with Flyway 5.x. I receive this when running the tests:
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at io.zonky.test.db.flyway.OptimizedFlywayTestExecutionListener.optimizedDbReset(OptimizedFlywayTestExecutionListener.java:131)
at io.zonky.test.db.flyway.OptimizedFlywayTestExecutionListener.beforeTestClass(OptimizedFlywayTestExecutionListener.java:92)
at org.springframework.test.context.TestContextManager.beforeTestClass(TestContextManager.java:195)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:60)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Error when initializing the data source
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
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.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
... 13 more
Caused by: java.lang.IllegalStateException: Error when initializing the data source
at com.google.common.base.Preconditions.checkState(Preconditions.java:459)
at io.zonky.test.db.flyway.DefaultFlywayDataSourceContext.getTarget(DefaultFlywayDataSourceContext.java:94)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
at com.sun.proxy.$Proxy121.getConnection(Unknown Source)
at org.flywaydb.core.internal.util.jdbc.JdbcUtils.openConnection(JdbcUtils.java:51)
at org.flywaydb.core.internal.database.DatabaseFactory.createDatabase(DatabaseFactory.java:67)
at org.flywaydb.core.Flyway.execute(Flyway.java:1634)
at org.flywaydb.core.Flyway.migrate(Flyway.java:1168)
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 30 more
from embedded-database-spring-test.
It's possible I am having some dependency issues with my Spring Boot 2 upgrade. I shall report back ;)
from embedded-database-spring-test.
The previous embedded-database-spring-test-core
maven artifact was the same as embedded-database-spring-test
artifact but with excluded auto-configuration. The same result is newly achieved by this:
<dependency>
<groupId>io.zonky.test</groupId>
<artifactId>embedded-database-spring-test</artifactId>
<version>1.3.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>io.zonky.test</groupId>
<artifactId>embedded-database-spring-test-autoconfigure</artifactId>
</exclusion>
</exclusions>
</dependency>
It is described in the documentation: https://github.com/zonkyio/embedded-database-spring-test#disabling-auto-configuration
So there is no need to use the embedded-database-spring-test-core
artifact at all. And that's why Flyway 5 does not work for you. Because the stack trace you have attached comes from the older embedded-database-spring-test-core:1.2.0
artifact and not from the newer embedded-database-spring-test:1.3.0
in which the support for Flyway 5 was added.
from embedded-database-spring-test.
The ClassNotFoundException
is strange, because the class is definitely part of embedded-database-spring-test:1.3.0
artifact. Try to clean up your local maven repository, maybe it will help.
from embedded-database-spring-test.
Oops. Forgot to report back. My issues were indeed caused by transitive dependency messiness in my upgrade to Spring Boot 2. All is working, and in the manner documented in the project README. Please close this ticket as "Won't Fix: Reporter is an Idiot" 😛
Thanks again for making this tool available and supporting it!
from embedded-database-spring-test.
Thanks for the feedback. I'm glad everything is working fine. 🙂
from embedded-database-spring-test.
Related Issues (20)
- [Q]: Is there a way to use the latest testcontainer version HOT 2
- Updated Dependencies leads to different Integration test behaviour HOT 6
- Build with -parameters compiler arg HOT 1
- Spring Boot 3.1 Support HOT 8
- Upgrade to Embedded Postgres 2.0.5
- All data providers being required when only a specific one is specified HOT 5
- Zonky "initdb" file getting returning file not found HOT 4
- Multiple PostgreSQL clusters (instances) HOT 1
- Tests using @FlywayTest(locationsForMigrate) failing after changing spring and flyway versions HOT 3
- Setting PostgreSQL max_connections value in properties gives PSQLException HOT 2
- Custom docker image with test data: How to use as a template HOT 4
- [Q]: Any plans to update testcontainers? HOT 5
- Flyway migration in multitenant application HOT 1
- Transitive vulnerable dependency HOT 1
- Use Zonky provider with PostGIS HOT 3
- For Flyway 9.9+ JavaMigration beans are not applied HOT 4
- Upgrade to Embedded Postgres 2.0.7
- db rider with zonkyio embedded postgresql HOT 3
- data type (1111, 'jsonb') not recognized and will be ignored HOT 1
- DockerClientProviderException HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embedded-database-spring-test.