Last active
October 17, 2023 08:55
-
-
Save truongquoc/fa0d1704cf3427a5b1468d602e562c86 to your computer and use it in GitHub Desktop.
DataSourceConfiguration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.flyway.public.locations=db/migration/public | |
spring.flyway.public.url=jdbc:postgresql://localhost:5432/postgres | |
spring.flyway.public.schemas=public | |
spring.flyway.public.user=postgres | |
spring.flyway.public.password=postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.core.platform.config; | |
import org.springframework.boot.autoconfigure.flyway.FlywayProperties; | |
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; | |
import org.springframework.boot.context.properties.ConfigurationProperties; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.context.annotation.Primary; | |
import java.util.HashMap; | |
import java.util.Map; | |
@Configuration | |
public class DataSourceConfiguration { | |
@Bean | |
@ConfigurationProperties("spring.datasource") | |
@Primary | |
public DataSourceProperties primaryDataSourceProperties() { | |
return new DataSourceProperties(); | |
} | |
@Bean | |
@ConfigurationProperties("spring.flyway") | |
public Map<String, FlywayProperties> primaryFlyway() { | |
return new HashMap<>(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.core.platform.config; | |
import jakarta.annotation.PostConstruct; | |
import org.flywaydb.core.Flyway; | |
import org.springframework.boot.autoconfigure.flyway.FlywayProperties; | |
import org.springframework.context.annotation.Configuration; | |
import java.util.Map; | |
import java.util.Optional; | |
@Configuration | |
public class FlywayDataSourceConfiguration { | |
private Map<String, FlywayProperties> flywayProperties; | |
public FlywayDataSourceConfiguration(Map<String, FlywayProperties> flywayProperties) { | |
this.flywayProperties = flywayProperties; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment