I’m using internationalization with Spring, and the properties file needs to be on the classpath. I also have some XML files that will need to be on the classpath. Is it acceptable to just include those resources inside the “src” in a sub-directory, and then let them build to the classpath, or is it better to add a different folder to the classpath during startup? I’m using Ant, but from the looks of it this was the approach Maven took (everything under src or test). I’m looking for the most widely accepted industry standards or better alternatives. Thanks!
I’m using internationalization with Spring, and the properties file needs to be on the
Share
Depends on the sole purpose of the resource in question. With this approach, any minor edit in such a resource file would thus require a full rebuild, redeploy and restart.
This may not necessarily harm for one-time-read startup and applicationwide configuration files like
web.xmlandapplication.xmland consorts since that would usually affect (or be affected by) changes in Java source code which require a full rebuild/redeploy/etc anyway.But in case of runtime files like i18n properties files and environment-specific configuration files (which would/could be managed by a non-developer like a serveradmin or a customer), it is not useful to package it inside the webapplication. This requires knowledge how to rebuild the webapp after edits. You would rather like to externalize it so that only a webapp restart is required to reflect the changes in the configuration, or maybe even not at all, like for
ResourceBundlewhich will just reload automagically.I myself usually put such files in a fixed path along the servletcontainer and add that path to the servletcontainer’s runtime classpath. In case of for example Tomcat, it’s configureable as
shared.loaderproperty in/conf/catalina.properties. E.g.Anything in this folder is then taken in the servletcontainer’s (and webapp’s) runtime classpath.