Reputation: 942
Hi all!!
Sorry if this is a dumb question, but I'm new to Maven and have reached an impasse!
Then, I get this error when I try to execute the jar.
java.io.FileNotFoundException: Unable to locate: properties/MyTest.properties at file:\C:\Dev\test.jar!\properties\MyTest.properties at ...
I'm wanting to access my properties both inside my IDE, and by running the jar from the command line when I deploy. I was thinking of having my properties files in a relative folder ../lib/ above the location of my jar file.
Inside my program I want to access the properties like so:
File testProperties = new File(
ClassLoader.getSystemResource("properties/MyTest.properties").getFile()
);
I tried adding this to my POM.xml
<transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>*.properties</resource>
<file>../*properties</file>
</transformer>
(Sorry the formatting got messed on the above code snippet!)
But, it's not working. I'd really appreciate any help in this. I've not posted all code as the code is really big, but I hope you can get an idea of what I'm trying to achieve.
Many thanks, Paul
Upvotes: 1
Views: 2831
Reputation: 942
Ok, I have a solution. Always the way, just after posting! But thanks for your reply.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>../lib</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 2