I’m using quarkus and the DevServices to start a postgresql database.
I want to initilize this database with a csv file. To do so I want to mount a csv file into the container of postgresql which is started with DevServices, so that I can initalize my database with "COPY … FROM" in the init script.
I follow the quarkus documentation for database dev services:
I’ve tried to add the following to my project in the application properties:
quarkus.datasource.devservices.volumes."/resources/init/"=/container/resources/
or
quarkus.datasource.devservices.volumes."src/main/resources/init/"=/container/resources/
The problem is that my csv file isn’t mounted correctly: The path /container/resources is in the postgres container but the resources folder is empty. It should contain the csv-file titanic.csv.
What path do I need to provide?
2
Answers
You need to provide an absolute path where your resource is located. However, since you want to bind a resource that is in your classpath already, you can use:
Where "." stands for the path at either "src/test/resources" if exists or "src/main/resources".
I hope it helps!
The example in the documentation explains it well, I think:
Your attempts are wrong for several reasons:
classpath:
variant instead of the filesystem variant you’re using."/resources/init/"
, which is an absolute path and probably doesn’t match anything (unless you have aresources
directory at the root of your filesystem and aninit
directory inside it, but I doubt that).src/main/resources/init/
assuming paths are relative to your project’s root directory, but I doubt they are. More likely they’re relative to whatever directory you start your application from (and in the case of tests with Maven, that’s probably./target
).In your case I’d try this instead?