spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 356 forks source link

Is there any way to load properties file from module library #1617

Closed jonaskahn closed 2 years ago

jonaskahn commented 2 years ago

I actually don't know it's a bug or feature question. Here is my situtation

I created a customized module following the Spring style (with spring.factories) and build as a library. I have some custom properties files in my module which already loaded by @PropertySource. After that, I put the custom library to my main app and everything works fine if I build a jar file. But it can't work if I try to build a native image. My question is did spring support to load custom properties file in library ?

bclozel commented 2 years ago

If your library is loading a property file on its own and this behavior is not automatically picked up during the native image compilation, you'll need to declare a resource hint in your library to let GraalVM know about this. You can use @ResourceHint or provide a JSON configuration file in your library JAR.

jonaskahn commented 2 years ago

Thank you so much, I'll try now