• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Copy any properties files to classes folder using maven

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have few properties files in my source folders..

src-main-java-com.xyz.business.forms

now when i install the war its able to get all java classes into the target but not the properties files. What should be done to get these properties files also..

Regards
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a typical maven project directory structure, resource files, such as properties file, should be placed in src/main/resources. For example, if you have a properties file named com.xyz.business.forms.properties, it should be located at:

src/main/resources/com/xyz/business/forms.properties

Maven will then automatically pick up the properties file and add it to the JAR or WAR file.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i agree that typically we are supposed to use resources folder..
but these properties files are used by these classes and they have be present in those folders only..
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But cant we have them in the same folder structure as in java..

rather than in having them in... resources/com/xyz/business/..

and build them
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but these properties files are used by these classes and they have be present in those folders only


The resources will be copied into the same target/classes directory as your compiled classes, and thus classes and resources will reside in the same folder. It is only during editing time that the java source file and resources appear in different locations.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic