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
@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