OpenLiberty Microprofile configuration example? - open-liberty

How can I pass MP config property file to OL on the command line? The wlp/bin/server.bat does not allow to pass even Java system properties...
I have looked at the OL MP config example and it assumes that the configuration is in the user user.home system property - not very useful.
I read the various WS Liberty docs and they require me to configure in XML the location where the property file is - also not very flexible. Other options involve using environment variables - not what I want.
What I want is something as flexible as:
bin/server.bat -Dmy.conig=c:/temp/myconfig.properties
This example above is similar to how Spring/SpringBoot does it. Thanks!

There are a few solutions for your use case:
Use your properties file as the default config in the app by placing your file inside the app under META-INF\microprofile-config.properties for jar or WEB-INF\classes\META-INF\microprofile-config.properties
Use your config as default jvm properties by using the instruction provided by covener. You can put the content of myconfig.properties into jvm.options or just rename your file to be jvm.options but place under one of the locations mentioned by covener.
Use your properties file as a custom config source. You can directly implement MicroProfile config api ConfigSource to parse this property file and provide the name value pairs for your app.
You can find more info about MicroProfile config from the open liberty guide (https://openliberty.io/guides/microprofile-config-intro.html)

Related

How to specify vault endpoint In springboot vault configuration without application name

In spring boot I wanted to read the properties from vault but I wanted to read vaulr secret token and the full path of the configuration endpoint from environment variable.
But if I give spring.cloud.vault.uri it is not working and for fetching from environmental variable I am using ${VAULT_TOKEN} but this also, not working.
spring.cloud.vault.uri=http://127.0.0.1:8200/secret/gs-vault-config/cloud/test
spring.cloud.vault.token=${VAULT_TOKEN}
I wanted to fetch both spring.cloud.vault.uri and spring.cloud.vault.token from environmental variable.
It's not a good idea.
Usually the file bootstrap.properties/bootstrap.yaml is placed separately from the project (project in /src, bootstrap config file in /config). It allows us to use it without rebuilding the project on parameter changes, and to use a dynamic configuration.
We already have a file with dynamic content, you want to create a separate dynamic config file with values for base dynamic config file! Tautology!

Quarkus: How to define and read properties file (or application.properties) outside application or at runtime?

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

Can Spring IDE support editing multiple application.yml files?

I'm using Eclipse Neon with Spring IDE Version 3.8.3.201612191259-RELEASE.
Whenever I create an application.yml file under src/main/resources it shows with a Spring embellished icon and allows me to see Spring Boot's configuration (for example see here: https://docs.spring.io/sts/nan/v370/NewAndNoteworthy.html).
For different profiles developers can either use a single YAML file with different sections for each spring.profiles via the --- notation. Developers might also choose to use separate YAML files named with the profile as part of the name (i.e. application-dev.yml) as noted in this link: https://www.mkyong.com/spring-boot/spring-boot-profile-based-properties-and-yaml-example/ .
The functionality provided by the Spring Boot YML Editor is very helpful not only for YAML editing but also because it allows auto-complete for Spring Boot's configuration. Is there a way to associate more than one file to be see by the Spring Boot YML Editor so that I can easily edit files like application-dev.yml in that editor? I know I can right-click on the file and have it open-with Spring Yaml Properties Editor but it would be nice if similar to configuring the Spring Bean support Config Files you could also pick multiple files to be seen as Spring YAML files (or perhaps look for all application-XXX.yml files and associate them to the editor).
The place where to specify file associations for the content type Spring Yaml Properties File can be found in the Eclipse preferences in General > Content Types. Search for the content type Yaml Content Type > Spring Yaml Properties File. In the box below you can add your required file associations.
As of Eclipse Neon you have to specify all your variants, e.g. application-prod.yml, application-some-profile.yml, ...
In Eclipse Photon it will be possible to use wildcards, e.g. application-*.yml. See https://www.eclipse.org/eclipse/news/4.8/M2/ for details

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 ...

Is there a property I can use to specify the location of my jetty.xml?

I am preparing a distribution of my application and it contains a Jetty. I would like to be able to specify the location of my jetty.xml file as a property via my JSW-generated scripts. Is there such a property that I can use?
Is there some page that lists the system properties that can be used Jetty?

Resources