How configs pick ENV value - osgi

We have a config folder structure in apps like this:
config
config.author.test
config.author.stage
These have config.runmode.env values
I wanted to know from where It picks the "env" value.
I thought it is coming from runmodes. but in the instances, stage or test is nowhere.
Can anyone please help me know where does the AEM configs picks the value or where do we define those env value. Is it in some OSGi configuration or from where.

If you are not using the AEM runtime for the AEM Cloud SDK, then the run modes can be set in other ways as well apart from the sling.properties file. So depending on how you are starting your AEM server check if the run modes have been specified using the other options.
If you are using the AEM runtime from the cloud SDK, then check if the Jar file is named as shown in the Quickstart jar startup modes.

Related

What is the difference between setting profile in quarkus with smallrye.config.profile or quarkus.profile

In quarkus the config is stored inside an application.properties file.
You can have multiple application-{profile}.properties files. {profile} is the name of the profile you want it to be.
When started with java -jar <pathToJar> -Dquarkus.profile=PROFILE_ONE the file application-PROFILEONE.properties is used. During startup of the app you can read that quarkus is using the PROFILE_ONE profile.
When started with java -jar <pathToJar> -Dsmallrye.config.profile=PROFILE_ONE the file application-PROFILEONE.properties is used. During startup of the app you can read that quarkus is using the PROD profile.
What exactly is the difference between both? Is it better to use smallrye.config.profile so that quarkus is still using the PROD profile? Is the PROD profile faster?
Thanks!
That is actually a bug. Internally, both use the same profile, but the log is reporting a different one when you use smallrye.config.profile, because it is only checking for quarkus.profile and then it defaults to prod (later in the code the actual profile is checked and used the correct one).
The message needs to be fixed. I'll look into it.

How we can organize different config profiles to use Quarkus profile in application.properties

I have different profiles based on environment wise and needs to load it. How i can achieve and also how to pass program arguments for Quarkus main application to take dev profile(spring.config.location=classpath:/config/dev/application.yml)
Is there a way to load databse configuration while starting #QuarkusMain. I have configured all the database configurations into one class and how this class can be load in main. Please suggest on this.
Quarkus 1.13 (and later), supports profile aware application.properties. Just name your file application-{profile}.properties and activate it with -Dquarkus.profile={profile}
If you want to load specific files, you can also use quarkus.config.locations. This is backed by SmallRye Config. Please check additional documentation here: https://smallrye.io/docs/smallrye-config/main/config/config.html

spring boot application properties based on spring profiles

Hi I want my spring boot web project to be deployed both on development and production environment and it should be run on specific profile based setting.
I googled on how to do that, and first of all that I have searched is defining application-{profile name}.properties properly in the src/main/resources classpath.
Now the problem is how to set profiles.
Since I am working on tomcat 8 in linux, there should be some configuration but I don't know how to do that.
and I am also curious that when my project is packaged as war file, java -jar {filename} -Dspring.active.profile=blahblah will not be work, but I think there is an alternative way.
plus, is there an way to set profile on tomcat 8 in Windows 10 ?
Thanks you
First:
I will recommend get rid of dedicated tomcat server and use embedded tomcat, jetty etc. Build your web apps as jar files and just run them. (of course if you don't have any limitations)
Second: You can do this either system property or env variable.
If you go with system property (order is important)
java -Dspring.profiles.active=blahblah -jar {filename}
If you go with env variable you need specify
SPRING_PROFILES_ACTIVE=blahblah

What is best practice management properties for me?

What can I do for best practice management properties?
I want to set different properties each deployed environment.
Some of my developer cannot detect my real server properties.
I want to build project using same command (using maven. not want to -P dev, -P production options)
I don't want to too many source code to load my properties.(like implements db access)
Can be continue my service without restart when some properties has been changed.
My service developed using spring-web.
You have 2 issues:
1) How to have your properties outside of the war file, I would suggest you do the following:
#PropertySource(value={"classpath:/config.properties", "file:${configRoot}/config.properties"}, ignoreResourceNotFound = true)
Then when you start your app you can specify configRoot as a system property to the JVM i.e -DconfigRoot=/var/config. You can then specify a default config which will be pulled from inside the war. Using the ignoreResourceNotFound if the file:${configRoot}/config.properties"} can not be found the first one will be used. i.e. you can have a default inside the war and override it at runtime with the JVM system parameter.
2) How to automatically refresh
Look at this answer to tell spring to refresh it's properties on a schedule:

Environment specific properties from user home in springboot

I am working on a spring boot application in which i have to set Environment specific properties from user home folder.
i dig Google for the same & found we can put different properties file (dev, test, production) under resources and then we have to tell spring boot which environment we want to use using spring.profiles.active=dev OR prod.
however, my requirement is quite different. i will put a file in user home in my system & want to read properties form that file. how can i do that, need guidance.
Helping hands will be highly appreciated.
From the Spring Boot docs:
You can also refer to an explicit location using the spring.config.location environment property (comma-separated list of directory locations, or file paths).
As the docs go on to state, this must be specified on the command line or as an environment variable.
$ java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties
We explain that use case in a Devoxx presentation using EnvironmentPostProcessor, please refer to this section of the presentation for more details. You can also find the code sample online.
Well, it seems in your case you dont need environment variable. For production server your property file will be staying in and in staging machine it is also staying at same place. So where ever you deploy it will pick from . IMO you don't need to set environment, you just have to point property file to
Now to define this path you have 2 ways..
- You can put static path in your code
- You can set environment variable like Property_Path and read it in spring boot application..
However If you want to go one step ahead, you can use spring cloud configuration manager, by passing application+profile name to it, CM can fetch property file from directly from git or file system for you ...

Resources