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

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

Browser testing is essential if you have a website or web applications that users interact with. Manual testing can be very helpful to an extent, but given the multiple browsers available, not to mention versions and operating system, testing everything manually becomes time-consuming and repetitive.

To help automate this process, Selenium is a popular choice for developers, as an open-source tool with a large and active community. What's more, we can further scale our automation testing by running on theLambdaTest cloud-based testing platform.

Read more through our step-by-step tutorial on how to set up Selenium tests with Java and run them on LambdaTest:

>> Automated Browser Testing With Selenium

Partner – Orkes – NPI EA (cat=Java)
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.

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 – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

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

Get up to speed with the core of Maven quickly, and then go beyond the foundations into the more powerful functionality of the build tool, such as profiles, scopes, multi-module projects and quite a bit more:

>> Download the core Maven eBook

1. Overview

In this tutorial, we’ll be looking at the role of a Maven artifact classifier. Following that, we’ll take a look at the various scenarios where they might be useful. Before concluding, we’ll briefly discuss the Maven artifact type as well.

2. What Is a Maven Artifact Classifier?

A Maven artifact classifier is an optional and arbitrary string that gets appended to the generated artifact’s name just after its version number. It distinguishes the artifacts built from the same POM but differing in content.

Let’s consider the artifact definition:

<groupId>com.baeldung</groupId>
<artifactId>maven-classifier-example-provider</artifactId>
<version>0.0.1-SNAPSHOT</version>

For this, the Maven jar plugin generates maven-classifier-example-provider-0.0.1-SNAPSHOT.jar.

2.1. Generating Artifacts With a Classifier

Let’s add a classifier configuration to the jar plugin:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.3.0</version>
            <executions>
                <execution>
                    <id>Arbitrary</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <classifier>arbitrary</classifier>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

As a result, the maven-classifier-example-provider-0.0.1-SNAPSHOT-arbitrary.jar along with the maven-classifier-example-provider-0.0.1-SNAPSHOT.jar is generated.

2.2. Consuming Artifacts With a Classifier

We’re now able to generate an artifact with a custom suffix using a classifier. Let’s see how we can use a classifier to consume the same.

In order to consume the default artifact, we don’t have to do anything special:

<dependency>
    <groupId>com.baeldung</groupId>
    <artifactId>maven-classifier-example-provider</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

But, to consume the artifact with the custom suffix “arbitrary”, we’ll need to use the classifier element within the dependency element:

<dependency>
    <groupId>com.baeldung</groupId>
    <artifactId>maven-classifier-example-provider</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <classifier>arbitrary</classifier>
</dependency>

After all this, a good question is why we would want to use a classifier? So, let’s look at some practical use cases where a classifier would be useful.

3. Using the Sources Classifier

We might have noticed that each Maven artifact is often accompanied by a “-sources.jar” artifact. It contains the source code, i.e., the .java files for the main artifact. It’s useful for debugging purposes.

3.1. Generating Sources Artifact

Firstly, let’s generate a sources jar for the maven-classifier-example-provider module. We’ll use maven-source-plugin to do that:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>3.2.1</version>
    <executions>
        <execution>
            <id>attach-sources</id>
            <phase>verify</phase>
            <goals>
                <goal>jar-no-fork</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Now, let’s run:

mvn clean install

As a result, the maven-classifier-example-provider-0.0.1-SNAPSHOT-sources.jar artifact is generated.

3.2. Consuming Sources Artifact

Now, to consume the sources artifact, there are several ways. Let’s take a look at one of them. We can fetch sources jar for selective dependencies using a classifier element within the dependency definition:

<dependency>
    <groupId>com.baeldung</groupId>
    <artifactId>maven-classifier-example-producer</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <classifier>sources</classifier>
</dependency>

Now, let’s run:

mvn clean install

As a result, the sources jar for this particular dependency is fetched. Generally, we don’t do this since it’ll unnecessarily pollute the POM. Hence, we usually prefer to use the capability of IDEs to attach the sources jar on-demand. Alternatively, we can also selectively fetch them via the mvn CLI command:

mvn dependency:sources -DincludeArtifactIds=maven-classifier-example-provider

In short, the key takeaway here is that the sources jar is referred to by using a sources classifier.

4. Using the Javadoc Classifier

In the same vein as the sources jar use case, we’ve Javadoc. It contains the documentation for the main jar artifact.

4.1. Generating Javadoc Artifact

Let’s use the maven-javadoc-plugin to generate the Javadoc artifact:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.6.2</version>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

With the plugin defined, let’s run:

mvn clean install

As a result, the maven-classifier-example-provider-0.0.1-SNAPSHOT-javadoc.jar artifact is generated.

4.2. Consuming Javadoc Artifact

Let’s now download the generated Javadoc from a consumer perspective via mvn:

mvn dependency:resolve -Dclassifier=javadoc -DincludeArtifactIds=maven-classifier-example-provider

We can notice the -Dclassifier=javadoc option which specifies the classifier as javadoc.

5. Using the Tests Classifier

Now, let’s look at a different use case that a classifier can serve. There might be various reasons we may want to get the tests jar of a module. For one, there could be certain test stubs that we might want to reuse. Let’s see how we can get the tests to jar independent of the main jar artifact via a classifier.

5.1. Generating Tests Jar

Firstly, let’s generate the tests jar for the maven-classifier-example-provider module. In order to do that, we’ll use the Maven jar plugin by specifying test-jar goal:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.3.0</version>
    <executions>
        <execution>
            <id>Test Jar</id>
            <goals>
                <goal>test-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Now, let’s run:

mvn clean install

As a result, the tests jar maven-classifier-example-provider-0.0.1-SNAPSHOT-tests.jar is generated and installed.

5.2. Consuming Tests Jar

And now, let’s get the tests jar dependency into our consumer module maven-classifier-example-consumer. We do this using the tests classifier:

<dependency>
    <groupId>com.baeldung</groupId>
    <artifactId>maven-classifier-example-provider</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <classifier>tests</classifier>
</dependency>

With that, we should be able to access the classes available in the test packages of maven-classifier-example-provider. 

6. Using Classifiers to Support Multiple Java Versions

Earlier, we had used an arbitrary classifier to build a second jar for our maven-classifier-example-provider module. Let’s now put that to more practical use.

Java is now releasing a newer version at a much faster cadence of 6 months. Consequently, it requires the module developers to be able to support multiple versions of Java. It might sound like a challenging task to build multiple jars for our modules compiled with different Java versions. That’s where the Maven classifier comes to the rescue. We can build multiple jars compiled with different Java versions using a single POM.

6.1. Compiling With Multiple Java Versions

Firstly, we’ll configure the Maven compiler plugin to generate compiled class files using both JDK 8 and JDK 11:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.12.1</version>
    <executions>
        <execution>
            <id>JDK 8</id>
            <phase>compile</phase>
            <goals>
                <goal>compile</goal>
            </goals>
            <configuration>
                <source>8</source>
                <target>8</target>
                <fork>true</fork>
            </configuration>
        </execution>
        <execution>
            <id>JDK 11</id>
            <phase>compile</phase>
            <goals>
                <goal>compile</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.outputDirectory}_jdk11</outputDirectory>
                <executable>${jdk.11.executable.path}</executable>
                <source>8</source>
                <target>11</target>
                <fork>true</fork>
            </configuration>
        </execution>
    </executions>
</plugin>

We’re setting up two execution blocks, one for Java 8 and the other for Java 11.

Following this, we’ve configured the outputDirectory to be different for Java 11. On the other hand, Java 8 compilation will use the default outputDirectory.

Next comes the source and target Java version configuration. The source code is written using Java 8, so we keep the source version as 8 and modify the target version for Java 11 execution block as 11.

We’ve also explicitly provided the executable path for Java 11’s compiler javac. For Java 8, Maven will use the default javac configured on the system which in this case is Java 8’s javac:

mvn clean compile

As a result, two folders will be generated within the target folder – classes and classes_jdk11.

6.2. Generating Jar Artifacts for Multiple Java Versions

Secondly, we can proceed to package the module into two separate jars with the Maven jar plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.3.0</version>
    <executions>
        <execution>
            <id>default-package-jdk11</id>
            <phase>package</phase>
            <goals>
                <goal>jar</goal>
            </goals>
            <configuration>
                <classesDirectory>${project.build.outputDirectory}_jdk11</classesDirectory>
                <classifier>jdk11</classifier>
            </configuration>
        </execution>
    </executions>
</plugin>

We can notice that the classifier is set to jdk11.

Now, let’s run:

mvn clean install

As a result, two jars are generated – maven-classifier-example-provider-0.0.1-SNAPSHOT-jdk11.jar and maven-classifier-example-provider-0.0.1-SNAPSHOT.jar. The first one was compiled using the Java 11 compiler and the second using the Java 8 compiler.

6.3. Consuming Jar Artifact of a Specific Java Version

And finally, the consumers of our module can choose which jar artifact is relevant for them, based on the Java version they are using. Let’s see how we can use these jars from a consumer’s perspective.

If we’re working on a Java 8 project we wouldn’t have to do anything special. We’ll just add a vanilla dependency:

<dependency>
    <groupId>com.baeldung</groupId>
    <artifactId>maven-classifier-example-provider</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

However, if we’re working on a Java 11 project we’ve to explicitly ask for the jar compiled with Java 11 via a classifier:

<dependency>
    <groupId>com.baeldung</groupId>
    <artifactId>maven-classifier-example-provider</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <classifier>jdk11</classifier>
</dependency>

7. Artifact Classifier vs. Artifact Type

Before we conclude this article, let’s have a brief look at artifact type. While artifact type and classifier are closely related, they are not interchangeable. An artifact type defines the packing format of an artifact e.g. POM or jar. It also translates to the file extension in most cases. It may also have a corresponding classifier too.

In other words, the artifact type deals with the packing of the artifact and may use a classifier to modify the name of the artifact generated.

The two use cases that we saw earlier with the Java Sources and the Javadoc are examples of artifact types that use sources and javadoc as classifiers.

8. Conclusion

In this article, we saw how classifiers provide a way to generate multiple artifacts from a single POM file. Using a classifier, the consumers can pick and choose from the various artifacts of a particular module as needed.

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

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

eBook Jackson – NPI EA – 3 (cat = Jackson)