Skip to main content

Posts

Showing posts with the label Environment

Spring : How to get Current Profiles in Spring Application

Points To Remember You can use the Environment interface  in package org.springframework.core.env to get the current profiles in spring application. You can make use of the following methods to get the information about the profiles. acceptsProfiles(String ...profiles)  - returns if the profiles given in input is active. getActiveProfiles()  - Gives a list of profiles explicitly made active for this enviornment. getDefaultProfiles()  - gives a set of profiles to be active by default if no active profile is set explicitly. See how to set and configure profiles in spring. Must Read :: What are profiles in Spring boot. How to get Active Profiles in an Environment All you need to do is autowire  the Environmnet bean. call the getActiveProfiles method of the bean. package com.ekiras.config; import org.springframework.stereotype.Component; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; @Component class...

Get Current Environment in Grails

How to create custom Environments in GRAILS. This is how you can specify the environments in your grails application. Below we have made five environments. production uat (custom) qa (custom) development test environments { production { grails.serverURL = "http://www.ekiras.com/" } uat { grails.serverURL = "http://uat.ekiras.com:8080/" } qa { grails.serverURL = "http://qa.ekiras.com:8080/" } development { grails.serverURL = "http://localhost:8080/${appName}" } test { grails.serverURL = "http://localhost:8080/${appName}" } } There are Five predefined environments in grails. APPLICATION CUSTOM DEVELOPMENT PRODUCTION TEST How to get Execute a particular Environment in GRAILS To run a particular environment in grails you can do the following grails -Denv=qa -Dserver.port=8080 run-app How to get Current Environment in Grails Controller You can get current environ...