Baeldung Pro – NPI EA (cat = Baeldung)
announcement - icon

Baeldung Pro comes with both absolutely No-Ads as well as finally with Dark Mode, for a clean learning experience:

>> Explore a clean Baeldung

Once the early-adopter seats are all used, the price will go up and stay at $33/year.

Partner – Microsoft – NPI EA (cat = Baeldung)
announcement - icon

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, visit the documentation page.

You can also ask questions and leave feedback on the Azure Container Apps GitHub page.

Partner – Microsoft – NPI EA (cat= Spring Boot)
announcement - icon

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, you can get started over on the documentation page.

And, you can also ask questions and leave feedback on the Azure Container Apps GitHub page.

Partner – Orkes – NPI EA (cat=Spring)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

Partner – Orkes – NPI EA (tag=Microservices)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

eBook – Guide Spring Cloud – NPI EA (cat=Spring Cloud)
announcement - icon

Let's get started with a Microservice Architecture with Spring Cloud:

>> Join Pro and download the eBook

eBook – Mockito – NPI EA (tag = Mockito)
announcement - icon

Mocking is an essential part of unit testing, and the Mockito library makes it easy to write clean and intuitive unit tests for your Java code.

Get started with mocking and improve your application tests using our Mockito guide:

Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Reactive – NPI EA (cat=Reactive)
announcement - icon

Spring 5 added support for reactive programming with the Spring WebFlux module, which has been improved upon ever since. Get started with the Reactor project basics and reactive programming in Spring Boot:

>> Join Pro and download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Jackson – NPI EA (cat=Jackson)
announcement - icon

Do JSON right with Jackson

Download the E-book

eBook – HTTP Client – NPI EA (cat=Http Client-Side)
announcement - icon

Get the most out of the Apache HTTP Client

Download the E-book

eBook – Maven – NPI EA (cat = Maven)
announcement - icon

Get Started with Apache Maven:

Download the E-book

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

eBook – RwS – NPI EA (cat=Spring MVC)
announcement - icon

Building a REST API with Spring?

Download the E-book

Course – LS – NPI EA (cat=Jackson)
announcement - icon

Get started with Spring and Spring Boot, through the Learn Spring course:

>> LEARN SPRING
Course – RWSB – NPI EA (cat=REST)
announcement - icon

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> The New “REST With Spring Boot”

Course – LSS – NPI EA (cat=Spring Security)
announcement - icon

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth, to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project.

You can explore the course here:

>> Learn Spring Security

Course – All Access – NPI EA (cat= Spring)
announcement - icon

All Access is finally out, with all of my Spring courses. Learn JUnit is out as well, and Learn Maven is coming fast. And, of course, quite a bit more affordable. Finally.

>> GET THE COURSE
Course – LSD – NPI EA (tag=Spring Data JPA)
announcement - icon

Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot.

Get started with Spring Data JPA through the guided reference course:

>> CHECK OUT THE COURSE

Partner – LambdaTest – NPI EA (cat=Testing)
announcement - icon

End-to-end testing is a very useful method to make sure that your application works as intended. This highlights issues in the overall functionality of the software, that the unit and integration test stages may miss.

Playwright is an easy-to-use, but powerful tool that automates end-to-end testing, and supports all modern browsers and platforms.

When coupled with LambdaTest (an AI-powered cloud-based test execution platform) it can be further scaled to run the Playwright scripts in parallel across 3000+ browser and device combinations:

>> Automated End-to-End Testing With Playwright

Course – Spring Sale 2025 – NPI EA (cat= Baeldung)
announcement - icon

Yes, we're now running our Spring Sale. All Courses are 25% off until 26th May, 2025:

>> EXPLORE ACCESS NOW

Course – Spring Sale 2025 – NPI (cat=Baeldung)
announcement - icon

Yes, we're now running our Spring Sale. All Courses are 25% off until 26th May, 2025:

>> EXPLORE ACCESS NOW

eBook – Guide Spring Cloud – NPI (cat=Cloud/Spring Cloud)
announcement - icon

Let's get started with a Microservice Architecture with Spring Cloud:

>> Join Pro and download the eBook

1. Overview

Netflix Archaius is a powerful configuration management library.

Simply put, it’s a framework that can be used to gather configuration properties from many different sources, offering fast, thread-safe access to them.

On top of this, the library allows properties to change dynamically at runtime, making it possible for the system to get these variations without having to restart the application.

In this introductory tutorial, we’ll set up a simple Spring Cloud Archaius configuration, we’ll explain what’s happening under the hood, and finally, we’ll see how Spring allows extending the basic setup.

2. Netflix Archaius Features

As we know, Spring Boot already provides instruments to manage externalized configurations, so why bother setting up a different mechanism?

Well, Archaius offers some handy and interesting features that aren’t contemplated by any other configuration framework. Some of its key points are:

  • Dynamic and Typed properties
  • A Callback mechanism that gets invoked on property mutations
  • Ready for use implementations of dynamic configuration sources such as URLs, JDBC and Amazon DynamoDB
  • A JMX MBean that can be accessed by Spring Boot Actuator or JConsole to inspect and manipulate the properties
  • Dynamic properties validation

These perks can be beneficial in many scenarios.

Therefore, Spring Cloud has worked on a library that allows to easily configure a ‘Spring Environment Bridge’ so that Archaius can read properties from the Spring Environment.

3. Dependencies

Let’s add the spring-cloud-starter-netflix-archaius to our application, it’ll add all the necessary dependencies to our project.

Optionally, we can also add spring-cloud-netflix to our dependencyManagement section and rely on its specification of the versions of the artifacts:

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-archaius</artifactId>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix</artifactId>
            <version>2.0.1.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Note: we can check Maven Central to verify we’re using the latest version of the starter library.

4. Usage

Once we add the required dependency, we’ll be able to access the properties managed by the framework:

DynamicStringProperty dynamicProperty 
  = DynamicPropertyFactory.getInstance()
  .getStringProperty("baeldung.archaius.property", "default value");

String propertyCurrentValue = dynamicProperty.get();

Let’s work on a short example to see how this is available just out-of-the-box.

4.1. Quick Example

By default, it manages dynamically all the properties defined in a file named config.properties in the application’s classpath.

So let’s add it to our resources folder with some arbitrary properties:

#config.properties
baeldung.archaius.properties.one=one FROM:config.properties

Now we’ll need a way to check the properties’ values at any specific moment. In this case, we’ll create a RestController that retrieves the values as a JSON response:

@RestController
public class ConfigPropertiesController {
	
    private DynamicStringProperty propertyOneWithDynamic
      = DynamicPropertyFactory.getInstance()
      .getStringProperty("baeldung.archaius.properties.one", "not found!");
	
    @GetMapping("/property-from-dynamic-management")
    public String getPropertyValue() {
	return propertyOneWithDynamic.getName() + ": " + propertyOneWithDynamic.get();
    }
}

Let’s try it out. We can send a request to this endpoint, and the service will retrieve the values stored in config.properties as expected.

No big deal so far, right? Ok, let’s go on and change the values of the property in the classpath file, without restarting the service. As a result, after a minute or so, a call to the endpoint should retrieve the new values. Pretty cool, isn’t it?

Next, we’ll try to understand what’s going on under the hood.

5. How Does It Work?

First of all, let’s attempt to comprehend the big picture.

Archaius is an extension of the Apache’s Commons Configuration library, adding some nice features like a polling framework for dynamic sources, with high throughput and thread-safe implementation.

The spring-cloud-netflix-archaius library comes then into play, merging all the different property sources, and auto-configuring the Archaius tools with these sources.

5.1. The Netflix Archaius Library

It operates defining a Composite Configuration, a collection of various configurations obtained from different sources.

Moreover, some of those Configuration Sources might support being polled at runtime for changes. Archaius provides interfaces and some pre-defined implementations to configure these types of sources.

The collection of sources is hierarchized so that if a property is present in multiple configurations, the final value will be the one in the topmost slot.

Finally, a ConfigurationManager handles the system-wide Configuration and deployment context. It can install the final Composite Configuration, or retrieve the installed one for modification.

5.2. Spring Cloud Support

The main task of the Spring Cloud Archaius library is to merge all the different configuration sources as a ConcurrentCompositeConfiguration and install it using the ConfigurationManager.

The order of precedence in which the library defines the sources is:

  1. Any Apache Common Configuration AbstractConfiguration bean defined in the context
  2. All the sources defined in the Autowired Spring ConfigurableEnvironment
  3. The default Archaius sources, which we saw in the example above
  4. Apache’s SystemConfiguration and EnvironmentConfiguration sources

Another useful feature this Spring Cloud library provides is the definition of an Actuator Endpoint to monitor and interact with the properties. Its usage is out of the scope of this tutorial.

6. Adapting and Extending the Archaius Configuration

Now that we have a better understanding of how Archaius works, we are in good shape to analyze how to adapt the configuration to our application, or how to extend the functionality using our configuration sources.

6.1. Archaius Supported Configuration Properties

If we want Archaius to take into account other configuration files similar to the config.properties one, we can define the archaius.configurationSource.additionalUrls system property.

The value is parsed to a list of URLs separated by a comma, so, for example, we can add this system property when we launch the application:

-Darchaius.configurationSource.additionalUrls=
  "classpath:other-dir/extra.properties,
  file:///home/user/other-extra.properties"

Archaius will read the config.properties file first, and then the other ones, in the specified order. Because of this, the properties defined in the latter files will have priority over the prior ones.

There are a couple of other system properties we can use to configure various aspects of the Archaius default configuration:

  • archaius.configurationSource.defaultFileName: the default configuration file name in the classpath
  • archaius.fixedDelayPollingScheduler.initialDelayMills: initial delay before reading the configuration source
  • archaius.fixedDelayPollingScheduler.delayMills: delay between two reads of the source; the default value is 1 minute

6.2. Adding Additional Configuration Sources with Spring

How could we add a different Configuration Source to be managed by the described framework? And how could we manage dynamic properties with higher precedence than the ones defined in the Spring Environment?

Reviewing what we mentioned in section 4.2, we can realize that the highest configurations in the Composite Configuration defined by Spring are the AbstractConfiguration beans defined in the context.

Thus, all we need to do is add an implementation of this Apache’s abstract class to our Spring Context using some of the functionality provided by Archaius, and the Spring’s autoconfiguration will spontaneously add it to the managed configuration properties.

To keep things simple, we’ll see an example where we configure a properties file similar to the default config.properties but with the difference of having a higher precedence than the rest of Spring environment and application properties:

@Bean
public AbstractConfiguration addApplicationPropertiesSource() {
    URL configPropertyURL = (new ClassPathResource("other-config.properties")).getURL();
    PolledConfigurationSource source = new URLConfigurationSource(configPropertyURL);
    return new DynamicConfiguration(source, new FixedDelayPollingScheduler());
}

Lucky for us, it contemplates several configuration sources that we can set up with almost no effort. Their configuration is out of the scope of this introductory tutorial.

7. Conclusion

To sum up, we’ve learned about Archaius and some of the cool features it offers to take advantage of configuration management.

Also, we saw how the Spring Cloud autoconfiguration library comes into play allowing us to use this library’s API conveniently.

The code backing this article is available on GitHub. Once you're logged in as a Baeldung Pro Member, start learning and coding on the project.
Baeldung Pro – NPI EA (cat = Baeldung)
announcement - icon

Baeldung Pro comes with both absolutely No-Ads as well as finally with Dark Mode, for a clean learning experience:

>> Explore a clean Baeldung

Once the early-adopter seats are all used, the price will go up and stay at $33/year.

Partner – Microsoft – NPI EA (cat = Spring Boot)
announcement - icon

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, visit the documentation page.

You can also ask questions and leave feedback on the Azure Container Apps GitHub page.

Partner – Orkes – NPI EA (cat = Spring)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

Partner – Orkes – NPI EA (tag = Microservices)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

eBook – HTTP Client – NPI EA (cat=HTTP Client-Side)
announcement - icon

The Apache HTTP Client is a very robust library, suitable for both simple and advanced use cases when testing HTTP endpoints. Check out our guide covering basic request and response handling, as well as security, cookies, timeouts, and more:

>> Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

Course – LS – NPI EA (cat=REST)

announcement - icon

Get started with Spring Boot and with core Spring, through the Learn Spring course:

>> CHECK OUT THE COURSE

Course – Spring Sale 2025 – NPI EA (cat= Baeldung)
announcement - icon

Yes, we're now running our Spring Sale. All Courses are 25% off until 26th May, 2025:

>> EXPLORE ACCESS NOW

Course – Spring Sale 2025 – NPI (All)
announcement - icon

Yes, we're now running our Spring Sale. All Courses are 25% off until 26th May, 2025:

>> EXPLORE ACCESS NOW

Partner – Microsoft – NPI (cat=Spring)
announcement - icon

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, visit the documentation page.

You can also ask questions and leave feedback on the Azure Container Apps GitHub page.

eBook Jackson – NPI EA – 3 (cat = Jackson)
eBook – eBook Guide Spring Cloud – NPI (cat=Cloud/Spring Cloud)