Search code examples
spring-boottestcontainersoracle-xe

Spring boot test containers


Is it possible to use test containers ie oracle-xe with spring boot, but have it used as DB for local deploy.. for instance get spring boot to start up in say develop profile and have the test container also start and be used for foe backend..

I have seen a few examples if it being used for tests, but then its torn down/shut down.

any ideas?

UPDATE:

So i managed to wire in the test container and start it up.. Got the spring properties set..

when the schema.sql files loads i get, an error no privleges... im trying to create a new schema and add some tables into it.. but it doesnt seem to work..

"no prviliges on tablespace 'SYSTEM'"

CREATE USER PM3 IDENTIFIED by PM3

 

CREATE TABLE PM3.JOBS (

    JOB_ID NUMBER(3) NOT NULL,

    CUSTOMER_ID NUMBER(3) NOT NULL,

    DESCRIPTION VARCHAR(200),

    constraint PK_JOB_ID primary key (JOB_ID)

);

Solution

  • Sergei Egorov, one of the core maintainers of Testcontainers, showed how to achieve this on his blog.

    It boils down to adding a new Spring Boot entry class and an initializer right before you start the Spring Boot application. This way you can reuse any Testcontainers setup for local development.