Reputation: 2936
In maven project is it necessary that all the properties file,xml files needs to be in resources folder.Means if I want my properties file is in src/main/java/com/search/search.properties
then I need to put it in resources/com/search/search.properties
.Is it necessary?
Because right now they are in java folder ,when I run maven project in hosted mode it runs properly. But when I create war it does not include that properties file in war/web-inf/classes/com/search/search.properties
.
When I put it in resources/com/search/search.properties
then and then only it include it in war folder.
Upvotes: 0
Views: 185
Reputation: 9537
It really depends on how you manage things. By default maven takes care if you use src/main/resources.
Also just verify that you have correct include/exclude tags in your resource tag under build.
<build>
<outputDirectory>${project.build.directory}/${project.artifactId}/WEB-INF/classes</outputDirectory>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources/</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<build>
Upvotes: 0
Reputation: 10190
According to the Maven standard directory layout you have to put Application/Library related resources into src/main/resources
, if you do not do this, when maven want to package your application (War, Jar or ...) only copy resource in src/main/resources
into your package.
Upvotes: 1