I have an AbstractBeanDefinitionParser and I'd like to inject a variable with #Value("${my.var}") or to get this value directly from org.springframework.core.env.Environment.
Any ideas how to do this?
I found the answer, I can obtain this from parseContext.
Environment environment = parserContext.getReaderContext().getEnvironment();
Related
I'm trying to create a new workflow file where I create an environment variable and use that variable in the value of some other environment variables, but it's not recognising it.
on:
workflow_dispatch:
env:
dev_environment: "my-environment"
working_dir_classic: "repo/${{ env.dev_environment }}/services/classic-service/"
working_dir_cron: "repo/${{ env.dev_environment }}/services/my-cron-service/"
Can anyone help?
Above is what I have currently, but I'm unsure what needs fixing.
I would like to use a dynamic placeholder inside the PropertySource value options.
This is in order to have the ability to have one file for each environment which overrides the default one. Just like application.properties and application-dev.properties.
Current setup:
#PropertySource("classpath:ione.properties")
I would like to have something like
#PropertySource("classpath:ione-{optionalEnvName}.properties")
Thus reading the --spring.profiles.active=dev option.
Thanks!
Run with:
-Dspring.profiles.active=dev
and then:
#PropertySource("classpath:ione-${spring.profiles.active}.properties")
should work
I currently have the following script:
var = foo
And the configuration of the email (Editable Email Publisher) I have it like this:
configuration Email Publisher
Reading in other questions, someone said that it worked for him using this:
${ENV, var="var"}
However, it does not work for me, can you help me please?
When you run a script that add environment variable the lifetime of this variable is only until the script ends.
You have plugin Environment Injector (was EnvInject Plugin) that using this plugin you can inject variable to all the job life time.
So if you want to add variable in the build section and to use it in the post build section you need to inject the variable.
I am Oozie currently, is it possible to get value of environment variable in the workflow.xml by means of EL function?
per "http://oozie.apache.org/docs/4.1.0/DG_ShellActionExtension.html" it appears you can do get it out, but i tried i could not get the value out as one of the jar which uses the class_path still complains missing class.
I know that I can access the environment value using the global $env variable, but is there the right way to get this value?
You're in luck - this was just added in Beta 4 - see here for details
Added App::environment method.
Edit: these are now a number of various ways to get the environment variable as of Laravel 4.1
App::environment()
app()->environment()
app()->env
$GLOBALS['env'] // not recommended - but it is possible
You can also specifically check for if the current environment is set to 'local'
App::isLocal()
app()->isLocal()
...or 'production'
App::isProduction()
app()->isProduction()
You can also specifically check for if the current environment is set to 'testing'
App::runningUnitTests()
app()->runningUnitTests()
You can also use app()->env.
In Laravel 4 and 5, the Laravel official docs suggest using:
$environment = App::environment();
You may also pass arguments to the environment method to check if the
environment matches a given value:
if (App::environment('local'))
{
// The environment is local
}
if (App::environment('local', 'staging'))
{
// The environment is either local OR staging...
}