I am building a jar using maven with simple maven install.
If I add a file to src/main/resources
it can be found on the classpath but it has a config folder where I want that file to go but moving it inside the config folder makes it disappear from the classpath.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
A cleaner alternative of putting your config file into a subfolder of src/main/resources would be to enhance your classpath locations. This is extremely easy to do with Maven.
For instance, place your property file in a new folder src/main/config, and add the following to your pom:
From now, every files files under src/main/config is considered as part of your classpath (note that you can exclude some of them from the final jar if needed: just add in the build section:
so that my-config.properties can be found in your classpath when you run your app from your IDE, but will remain external from your jar in your final distribution).
If you place anything in
src/main/resources
directory, then by default it will end up in your final*.jar
. If you are referencing it from some other project and it cannot be found on a classpath, then you did one of those two mistakes:*.jar
is not correctly loaded (maybe typo in the path?)/src/main/resources/conf/settings.properties
is seen on classpath asclasspath:conf/settings.properties