{"id":19,"date":"2008-09-03T15:57:01","date_gmt":"2008-09-03T10:27:01","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=19"},"modified":"2015-07-10T13:33:54","modified_gmt":"2015-07-10T08:03:54","slug":"externalize-application-properties-in-a-grails-app","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/externalize-application-properties-in-a-grails-app\/","title":{"rendered":"Externalize application properties in a Grails app"},"content":{"rendered":"<p>Externalizing properties of an application has really come a long way, especially if you are using Grails.<\/p>\n<p>Just want to share as a quick tip how easy it is to externalize the <a title=\"Grails Outsourcing Services\" href=\"http:\/\/www.tothenew.com\/grails-application-development\">properties in a Grails application<\/a>.<\/p>\n<p>This is what all we have to do in-order to get something from a properties file.<\/p>\n<p>In <strong>config.groovy<\/strong> include the properties that you want to be outside your groovy code.<\/p>\n<p>For Example :<\/p>\n<pre>smtpUserName = \"&lt;someid@test.com&gt;\"<\/pre>\n<pre>hostname = \"yourHostName\"<\/pre>\n<p><span style=\"text-decoration: underline;\">In order to read these properties in your Grails controller:<\/span><\/p>\n<pre>def smtpUserName = grailsApplication.config.smtpUserName<\/pre>\n<p><span style=\"text-decoration: underline;\">In order to read the properties from Grails Service class:<\/span><\/p>\n<pre>def smtpUserName =\u00a0 ConfigurationHolder.config.smtpUserName<\/pre>\n<pre><\/pre>\n<p>Easy, isn&#8217;t it?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Externalizing properties of an application has really come a long way, especially if you are using Grails. Just want to share as a quick tip how easy it is to externalize the properties in a Grails application. This is what all we have to do in-order to get something from a properties file. In config.groovy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":10},"categories":[7],"tags":[4840,9],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/19"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}