Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
40351c40
Commit
40351c40
authored
Oct 27, 2015
by
Vedran Pavic
Committed by
Stephane Nicoll
Oct 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix binding of Flyway's baselineVersion property
See gh-4317
parent
791c50d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
FlywayAutoConfiguration.java
...rk/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
+22
-0
FlywayAutoConfigurationTests.java
...ot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
+12
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
View file @
40351c40
...
@@ -21,6 +21,7 @@ import javax.persistence.EntityManagerFactory;
...
@@ -21,6 +21,7 @@ import javax.persistence.EntityManagerFactory;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
org.flywaydb.core.Flyway
;
import
org.flywaydb.core.Flyway
;
import
org.flywaydb.core.api.MigrationVersion
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
...
@@ -33,9 +34,11 @@ import org.springframework.boot.autoconfigure.data.jpa.EntityManagerFactoryDepen
...
@@ -33,9 +34,11 @@ import org.springframework.boot.autoconfigure.data.jpa.EntityManagerFactoryDepen
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationPropertiesBinding
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.core.io.DefaultResourceLoader
;
import
org.springframework.core.io.DefaultResourceLoader
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean
;
import
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean
;
...
@@ -47,6 +50,7 @@ import org.springframework.util.Assert;
...
@@ -47,6 +50,7 @@ import org.springframework.util.Assert;
*
*
* @author Dave Syer
* @author Dave Syer
* @author Phillip Webb
* @author Phillip Webb
* @author Vedran Pavic
* @since 1.1.0
* @since 1.1.0
*/
*/
@Configuration
@Configuration
...
@@ -57,6 +61,12 @@ import org.springframework.util.Assert;
...
@@ -57,6 +61,12 @@ import org.springframework.util.Assert;
HibernateJpaAutoConfiguration
.
class
})
HibernateJpaAutoConfiguration
.
class
})
public
class
FlywayAutoConfiguration
{
public
class
FlywayAutoConfiguration
{
@Bean
@ConfigurationPropertiesBinding
public
StringToMigrationVersionConverter
stringToMigrationVersionConverter
()
{
return
new
StringToMigrationVersionConverter
();
}
@Configuration
@Configuration
@ConditionalOnMissingBean
(
Flyway
.
class
)
@ConditionalOnMissingBean
(
Flyway
.
class
)
@EnableConfigurationProperties
(
FlywayProperties
.
class
)
@EnableConfigurationProperties
(
FlywayProperties
.
class
)
...
@@ -158,4 +168,16 @@ public class FlywayAutoConfiguration {
...
@@ -158,4 +168,16 @@ public class FlywayAutoConfiguration {
}
}
/**
* Converts a String to a {@link MigrationVersion}.
*/
private
static
class
StringToMigrationVersionConverter
implements
Converter
<
String
,
MigrationVersion
>
{
@Override
public
MigrationVersion
convert
(
String
source
)
{
return
MigrationVersion
.
fromVersion
(
source
);
}
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
View file @
40351c40
...
@@ -23,6 +23,7 @@ import java.util.Map;
...
@@ -23,6 +23,7 @@ import java.util.Map;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
org.flywaydb.core.Flyway
;
import
org.flywaydb.core.Flyway
;
import
org.flywaydb.core.api.MigrationVersion
;
import
org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
;
import
org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -56,6 +57,7 @@ import static org.junit.Assert.assertThat;
...
@@ -56,6 +57,7 @@ import static org.junit.Assert.assertThat;
* @author Dave Syer
* @author Dave Syer
* @author Phillip Webb
* @author Phillip Webb
* @author Andy Wilkinson
* @author Andy Wilkinson
* @author Vedran Pavic
*/
*/
public
class
FlywayAutoConfigurationTests
{
public
class
FlywayAutoConfigurationTests
{
...
@@ -195,6 +197,16 @@ public class FlywayAutoConfigurationTests {
...
@@ -195,6 +197,16 @@ public class FlywayAutoConfigurationTests {
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
}
}
@Test
public
void
overrideBaselineVersion
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"flyway.baseline-version=0"
);
registerAndRefresh
(
EmbeddedDataSourceConfiguration
.
class
,
FlywayAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
Flyway
flyway
=
this
.
context
.
getBean
(
Flyway
.
class
);
assertThat
(
flyway
.
getBaselineVersion
(),
equalTo
(
MigrationVersion
.
fromVersion
(
"0"
)));
}
private
void
registerAndRefresh
(
Class
<?>...
annotatedClasses
)
{
private
void
registerAndRefresh
(
Class
<?>...
annotatedClasses
)
{
this
.
context
.
register
(
annotatedClasses
);
this
.
context
.
register
(
annotatedClasses
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment