@ -21,12 +21,13 @@ import org.slf4j.Logger;
@@ -21,12 +21,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory ;
import org.springframework.context.annotation.Configuration ;
import org.springframework.context.annotation.Profile ;
import org.springframework.jdbc.core.JdbcTemplate ;
import org.springframework.jdbc.datasource.DriverManagerDataSource ;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator ;
import org.testcontainers.containers.OracleContainer ;
/ * *
* { @link DataSource } setup for Oracle Database XE . Starts a docker container with a Oracle database .
* { @link DataSource } setup for Oracle Database XE . Starts a docker container with an Oracle database .
*
* @see < a href =
* "https://blogs.oracle.com/oraclemagazine/deliver-oracle-database-18c-express-edition-in-containers" > Oracle
@ -53,16 +54,25 @@ public class OracleDataSourceConfiguration extends DataSourceConfiguration {
@@ -53,16 +54,25 @@ public class OracleDataSourceConfiguration extends DataSourceConfiguration {
if ( ORACLE_CONTAINER = = null ) {
LOG . info ( "Oracle starting..." ) ;
OracleContainer container = new OracleContainer ( "springci/spring-data-oracle-xe-prebuild:18.4.0 " ) . withReuse ( true ) ;
OracleContainer container = new OracleContainer ( "gvenzl/oracle-xe:18.4.0-slim " ) . withReuse ( true ) ;
container . start ( ) ;
LOG . info ( "Oracle started" ) ;
ORACLE_CONTAINER = container ;
}
String jdbcUrl = ORACLE_CONTAINER . getJdbcUrl ( ) . replace ( ":xe" , "/XEPDB1" ) ;
initDb ( ) ;
return new DriverManagerDataSource ( jdbcUrl , ORACLE_CONTAINER . getUsername ( ) , ORACLE_CONTAINER . getPassword ( ) ) ;
return new DriverManagerDataSource ( ORACLE_CONTAINER . getJdbcUrl ( ) , ORACLE_CONTAINER . getUsername ( ) ,
ORACLE_CONTAINER . getPassword ( ) ) ;
}
private void initDb ( ) {
final DriverManagerDataSource dataSource = new DriverManagerDataSource ( ORACLE_CONTAINER . getJdbcUrl ( ) , "SYSTEM" ,
ORACLE_CONTAINER . getPassword ( ) ) ;
final JdbcTemplate jdbc = new JdbcTemplate ( dataSource ) ;
jdbc . execute ( "GRANT ALL PRIVILEGES TO " + ORACLE_CONTAINER . getUsername ( ) ) ;
}
@Override