Skip to content

Instantly share code, notes, and snippets.

@truongquoc
Last active October 17, 2023 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save truongquoc/fa0d1704cf3427a5b1468d602e562c86 to your computer and use it in GitHub Desktop.
Save truongquoc/fa0d1704cf3427a5b1468d602e562c86 to your computer and use it in GitHub Desktop.
DataSourceConfiguration
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
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<>();
}
}
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