Currently we developing a web application on we use spring framework, this application contains several modules, so we chose to put all the configuration in a module named "shared-module" when we using the IDE we can specify the propority file of profile but when we try to launch this application outside of IDE we can not point to the correct property file.
Application strucuture:
shared-module--(injected)-->application.jar
See Externalized Configuration properties order described here. This documentation have clear description of supported application and profile specific properties. Please provide additional information if it does not address specific scenario you've problem with.
Related
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
In Quarkus, We have properties file inside project itself called application.properties.
Is there any Quarkus way to define external properties file in my use case like i am developing a mail sender and i want to add recipients in future.
Is it possible to give application.properties outside at local and inject it at runtime?
You can add a configuration file in your application working directory under config/application.properties : https://quarkus.io/guides/config#overriding-properties-at-runtime
There is ongoing discussion to have more runtime configuration capabilities here: https://github.com/quarkusio/quarkus/issues/1218
You can achieve this by keeping .properties (or .yaml) in Spring Cloud Config Server.
It's really easy to set it up. It's is well documented in following link (official documentation):
Quarkus - Reading properties from Spring Cloud Config Server
As loïc says, you can follow the convention and create a config/application.properties. You can also use the property quarkus.config.locations to specify additional config locations. It can be defined at runtime like below
java -Dquarkus.config.locations=app-config/config.properties -jar my-app.jar
I have created a spring-boot starter project and linked Azure Application insight to it. The properties like instrumentation- key is defined in "application.properties". On launching the application it is correctly linked to App Insight as can be verified by Live Metrics Stream.
However same application fails to connect to Azure App Insight if logback.xml is included in project (in resources), in this case to connect to App insight I have to include ApplicationInsights.xml as well.
But I do not want to use "ApplicationInsights.xml" in my application for 2 reasons. 1. I do not want multiple configuration files. 2. I am not able to inject key , i.e. not able to externalize key which might come as vm arguments or environment variable.
Defining InstrumentationKey and other configuration in application.properties works only when logback.xml is not present.
sample project (asset-register.zip) can be found at https://github.com/Microsoft/ApplicationInsights-Java/issues/710
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:
Is there a way to use Spring 3 property place holder to load application specific properties without conflicting with other applications within the same tomcat/jvm ?
All of your application specific properties are residing inside your jar and tomcat will only make them available to your application.
Just put them under webapps/${app_war}/WEB-INF/classes/app.properties and your spring config will pick them up from classpath.
System properties via -D startup parameters are shared, but not application specific.