Running spring boot native application, cannot load resource file

Viewed 438

I'm trying to compile a Spring Boot application to a native application and run this using docker. I'm using spring-graalvm-native version 0.8.5 and Spring Boot version 2.4.1. I'm trying to build the docker container using spring-boot-maven-plugin using the command:

mvn spring-boot:build-image

In the code, I want to read a file from resources and I'm trying to load it like this:

@Value("classpath:my.json")
Resource resourceFile;

The compilation step works fine, but the problem is that when I run the docker image my.json file isn't loaded, it cannot be found.

I run native-image-agent and it generated the META-INF folder where the resources-config.json file has the my.json pattern added.

I also tried to configure spring-boot-maven-plugin and I added:

-H:IncludeResources='.*/my.json$'

But none of these configurations worked, can you help me figure out what the problem is?

Best regards

Project structure:

enter image description here

0 Answers
Related