Created
March 6, 2019 11:55
-
-
Save Romeh/ff32ad219e88f5fa2d4a8c7abdb4e37f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@Bean | |
public DataSource dataSource() { | |
DriverManagerDataSource ds = new DriverManagerDataSource(); | |
ds.setDriverClassName("org.postgresql.Driver"); | |
// here we reference the static test container variable in our test case to get the used the connection details | |
ds.setUrl(format("jdbc:postgresql://%s:%s/%s", postgreSQLContainer.getContainerIpAddress(), | |
postgreSQLContainer.getMappedPort( | |
PostgreSQLContainer.POSTGRESQL_PORT), postgreSQLContainer.getDatabaseName())); | |
ds.setUsername(postgreSQLContainer.getUsername()); | |
ds.setPassword(postgreSQLContainer.getPassword()); | |
ds.setSchema(postgreSQLContainer.getDatabaseName()); | |
return ds; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment