Home » Java » Enterprise Java » Configuring plain Java projects using MicroProfile Config

About Sebastian Daschner

Sebastian Daschner is a self-employed Java consultant and trainer. He is the author of the book 'Architecting Modern Java EE Applications'. Sebastian is a Java Champion, Oracle Developer Champion and JavaOne Rockstar.

Configuring plain Java projects using MicroProfile Config

If you’re in the Enterprise Java space, you’re probably aware that you can use MicroProfile Config to configure your applications. This also works with plain Java projects, without an enterprise runtime, by using a MicroProfile implementation such as Smallrye. In this video, I’m showing how to do this, and in which circumstances it might be helpful:

The example uses a programmatic lookup via ConfigProvider:

String value = ConfigProvider.getConfig().getValue("config.value", String.class);
System.out.println("value = " + value);

In the video, I’m making use of another ConfigSource that reads the entries from a .env file, which overrides entries in microprofile-config.properties:

# META-INF/microprofile-config.properties

# .env, in current working directory


For this example to work, we need to activate Smallrye’s DotEnvConfigSourceProvider via Java Service Loader, by adding a file META-INF/services/​org.eclipse.microprofile.config.spi​.ConfigSourceProvider that contains the fully-qualified class name:


You can check out the ConfigExample code on GitHub.

In order to see a fully-fledged example which uses this approach, have a look at my post on Running complex project setups with Testcontainers.

Published on Java Code Geeks with permission by Sebastian Daschner, partner at our JCG program. See the original article here: Configuring plain Java projects using MicroProfile Config

Opinions expressed by Java Code Geeks contributors are their own.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments