Reputation: 186
I have a maven project with spring dependencies under eclipse. It runs correctly under eclipse, but when I try to export project to jar file with eclipse export runable jar option. Generated jar file can not run because it can not find xml files which are placed under src/main/resources
I noticed that in jar file resources are placed under myFile.jar/resources/META-INF/config.xml instead myFile.jar/META-INF/config.xml
To fix this problem I edit class path and remove including="*/.java" and add excluding properties. Working one: Updated by maven:
But when i update project with maven (alt+F5) it updates .classpath file and problem reappears.
To fix this i added src/main/resources /.xml /.java [...]
But it always adds the including="*/.java" to .classpath file.
My question is how can I configure maven so that export jar file would be placed under myFile.jar/META-INF/config.xml even I update project with maven.
Any help would be great.
Thanks.
Upvotes: 0
Views: 959
Reputation: 4249
Is you executable JAR file created with maven?
If so you could use the Resource plugin to place the configuration file Where you expect to find them.
Upvotes: 0
Reputation: 5869
Use Maven-Shade-Plugin.
From the plugin's page:
This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies.
The plugin bundles all the dependencies into a runable jar file.
It also lets you minimize the size of the jar file by using the following code:
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
See my question for some information regarding minimization.
Upvotes: 1