By convention, the directory src/main/resources
contains the resources that will be used by the application. So Maven will include them in the final JAR
.
Thus in your application, you will access them using the getResourceAsStream()
method, as the resources are loaded in the classpath.
If you need to have them outside your application, do not store them in src/main/resources
as they will be bundled by Maven. Of course, you can exclude them (using the link given by chkal) but it is better to create another directory (for example src/main/external-resources
) in order to keep the conventions regarding the src/main/resources
directory.
In the latter case, you will have to deliver the resources independently as your JAR file (this can be achieved by using the Assembly plugin). If you need to access them in your Eclipse environment, go to the Properties
of your project, then in Java Build Path
in Sources
tab, add the folder (for example src/main/external-resources
). Eclipse will then add this directory in the classpath.