I'd like to add an XML file to my project's dependencies. I've been pretty successful in doing this but unfortunately I've found that my XML file is not added to the classpath (which kind of makes sense as it is not a jar file).
The reason I want to have the XML file in my classpath is so that I could load it as a resource.
What is the recommended way of doing this, if it is at all recommended?
Thanks
Add a Java Maven Dependency to the Utility Project Right-click the utility project, and select Maven>Add Dependency. Type a dependency name in the Enter groupID… field (e.g., commons-logging) to search for a dependency. Select the dependency, and click OK.
Click the dependency you want to add to your application. You can use Ctrl+click to select multiple non adjacent dependencies, or Shift+click to select multiple adjacent dependencies. Drop the dependencies to the Manual Dependencies folder of the application. Save the application.
You can find this in Window > Preferences > Maven > User Settings , and then point Global Settings to your external maven settings. xml . Then i removed the broken projects and re-added them, and the Maven Dependencies library appeared again.
Yes, put it in the resource folder. By default that's src/main/resources
. If you put a file in there, it'll become available in your classpath.
Alternatively, you could modify your pom to say your folder where the xml file is in is a resource folder. But, I consider this a bad practice if your xml file is under your src/main/java
directory.
This solution works for me. I am using a WMQ table channel file from a Nexus repository.
<dependency>
<groupId>wmq</groupId>
<artifactId>wmq-channel-tab-file</artifactId>
<version>1.0.0</version>
<type>tab</type>
</dependency>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>wmq</groupId>
<artifactId>wmq-channel-tab-file</artifactId>
<version>1.0.0</version>
<type>tab</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>
<destFileName>wmq-channel-tab-file.tab</destFileName>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</execution>
</executions>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With