<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Codedrop™ Weblog &#187; Spring</title>
	<atom:link href="http://www.codedrop.ca/blog/archives/tag/spring/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codedrop.ca/blog</link>
	<description>Drop'n some code and other tech tidbits...</description>
	<lastBuildDate>Mon, 26 Jul 2010 16:45:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spring Application Configuration w/External Overrides</title>
		<link>http://www.codedrop.ca/blog/archives/135</link>
		<comments>http://www.codedrop.ca/blog/archives/135#comments</comments>
		<pubDate>Tue, 29 Sep 2009 17:45:48 +0000</pubDate>
		<dc:creator>groll</dc:creator>
				<category><![CDATA[Spring]]></category>
		<category><![CDATA[Configuration]]></category>

		<guid isPermaLink="false">http://www.codedrop.ca/blog/archives/135</guid>
		<description><![CDATA[Found a great article at carbonfive.com on how to configure application with Spring utilizing various techniques.&#160; My favorite from this article is included below:

Optional External Properties

There’s another use case that applies to some projects. Often in non-developer environments, system admins want to keep properties for the environment outside of the deployable archive or the application [...]]]></description>
			<content:encoded><![CDATA[<p>Found a great <a target="_blank" href="http://blog.carbonfive.com/?s=ignoreunresolvableplaceholders">article</a> at carbonfive.com on how to configure application with Spring utilizing various techniques.&nbsp; My favorite from this article is included below:</p>
<p>
<h4>Optional External Properties</h4>
<p>
<p>There’s another use case that applies to some projects. Often in non-developer environments, system admins want to keep properties for the environment outside of the deployable archive or the application server, and they don’t want to deal with keeping those files in a Tomcat context file; they prefer a simple properties file. They also don’t want to have to place the file in a hard-coded location (e.g. /var/acmeapp/application.properties) or they may keep configuration for multiple servers in the same network directory, each file names after the server. With a little trickery, it’s easy to support an optional external properties file that isn’t in a hard-coded location. The location of the file is passed as a single system property to the JVM, for example: -Dconfig=file://var/acmeapp/server1.properties. </p>
<p>
<p>Here’s the configuration to make it happen:</p>
<p>
<pre>
&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
    &lt;property name="ignoreUnresolvablePlaceholders" value="true"&gt;
&lt;/property&gt;

&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
    &lt;property name="ignoreResourceNotFound" value="true"&gt;
    &lt;property name="location" value="${config}"&gt;
&lt;/property&gt;

&lt;/property&gt;&lt;/bean&gt;&lt;/bean&gt;
</pre>
<p>
<p>The first definition enables basic property resolution through system properties (in fallback mode). The second bean loads the resource from the location resolved from the system property -Dconfig. All spring resource urls are supported, making this very flexible.</p>
<p><b>Best Practices</b><br /> 
<ul>	
<li>Deploy the same exact artifact (e.g. war, ear, etc) across all environments by externalizing configuration. This may seem daunting, but the emergent benefits are huge in terms of simplicity.</li>
<li>Only make things that can safely change across environments configurable. Also, only things that need to be configurable should be configurable, it’s easy to go overboard.</li>
<li>Configure the minimal properties search path that meets your requirements.</li>
<li>When looking for properties files in the project tree, use classpath resources whenever possible. This makes finding those files easy, consistent, and insensitive to the working-dir, which is great when running tests from your IDE and command line.</li>
<li>Aim for a zero-configuration check-out, build, run-tests cycle for the environment where its happens most: development.</li>
<p>  </ul>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=ed015424-ae25-8021-b968-4565aed264fa" /></div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Spring+Application+Configuration+w%2FExternal+Overrides+http://kag74.th8.us" title="Post to Twitter"><img class="nothumb" src="http://www.codedrop.ca/blog/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Spring+Application+Configuration+w%2FExternal+Overrides+http://kag74.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codedrop.ca/blog/archives/135/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
