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

Modern software architecture is often broken. Slow deliveryleads to missed opportunities, innovation is stalled due toarchitectural complexities, and engineering resources areexceedingly expensive.

Orkes is the leading workflow orchestration platformbuilt 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 canfocus on building mission critical applications without worryingabout infrastructure maintenance to meet goals and, simply put,taking new products live faster and reducing total cost ofownership.

Try a14-Day FreeTrial of Orkes Conductor today.

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

Modern software architecture is often broken. Slow deliveryleads to missed opportunities, innovation is stalled due toarchitectural complexities, and engineering resources areexceedingly expensive.

Orkes is the leading workflow orchestration platformbuilt 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 canfocus on building mission critical applications without worryingabout infrastructure maintenance to meet goals and, simply put,taking new products live faster and reducing total cost ofownership.

Try a14-DayFree 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 SpringCloud:

>> Join Pro and download theeBook

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

Mocking is an essential part of unit testing, and the Mockitolibrary makes it easy to writeclean and intuitive unittests for your Java code.

Get started with mocking and improve your application testsusing ourMockito guide:

Download theeBook

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

Handling concurrency in an application can be a tricky processwith manypotential pitfalls. A solid grasp of thefundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications withourJava Concurrency guide:

>>Download the eBook

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

Spring 5 added support for reactive programming with the SpringWebFlux module, which has been improved upon ever since. Getstarted with the Reactor project basics andreactive programmingin Spring Boot:

>> Join Pro anddownload the eBook

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

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

But these can also be overused and fall into some commonpitfalls.

Toget a better understanding on how Streams work and howto combine them with other language features, check out our guideto Java Streams:

>> Join Proand download the eBook

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

Do JSON right with Jackson

Download theE-book

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

Get the most out of the Apache HTTP Client

Download theE-book

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

Working on getting your persistence layer right with Spring?

Explore theeBook

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 theLearnSpring course:

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

Explore Spring Boot 3 and Spring 6 in-depth through building afullREST 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 advancedfunctionality within the Core to the deep OAuth support in theframework.

I built the security material astwo full courses - Core andOAuth, to get practical with these more complex scenarios. Weexplore when and how to use each feature andcode through it onthe backing project.

You can explore the course here:

>> Learn SpringSecurity

Course – LSD – NPI EA (tag=Spring Data JPA)
announcement - icon

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

Get started with Spring Data JPA through the guided referencecourse:

>> CHECK OUT THECOURSE

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

Get up to speed withthe core of Maven quickly, and thengo beyond the foundations into the morepowerfulfunctionality of the build tool, such as profiles, scopes,multi-module projects and quite a bit more:

>> Download the coreMaven eBook

Table of Contents

  1. Overview
  2. Basic Spring Dependencies with Maven
  3. Spring Persistence with Maven
  4. Spring MVC with Maven
  5. Spring Security with Maven
  6. Spring Test with Maven
  7. Using Milestones
  8. Using Snapshots
  9. Conclusion

1. Overview

This tutorial illustrates how to set upthe Spring dependencies via Maven. The latest Spring releases can be foundon Maven Central.

2. Basic Spring Dependencies With Maven

Spring is designed to be highly modular – using one part of Spring should not and does not require another. For example, the basic Spring Context can be without the Persistence or the MVC Spring libraries.

Let’s start with a fundamental Maven setup which will only usethespring-context dependency:

<properties>    <org.springframework.version>5.2.8.RELEASE</org.springframework.version></properties><dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-context</artifactId>    <version>${org.springframework.version}</version>    <scope>runtime</scope></dependency>

This dependency –spring-context – defines the actual Spring Injection Container and has a small number of dependencies:spring-core,spring-expression,spring-aop, andspring-beans. These augment the container by enabling support for some of thecore Spring technologies: the Core Spring utilities, theSpring Expression Language (SpEL), theAspect-Oriented Programming support and theJavaBeans mechanism.

Note we’re defining the dependency in theruntime scope – this will make sure that there are no compile-time dependencies on any Spring specific APIs. For more advanced use cases, theruntime scope may be removed from some selected Spring dependencies, but for simpler projects, there isno need to compile against Spring to make full use of the framework.

Also, note that JDK 8 is the minimum Java version required for Spring 5.2. It also supports JDK 11 as the current LTS branch and JDK 13 as the latest OpenJDK release.

3. Spring Persistence With Maven

Let’s now look atthe persistence Spring dependencies – mainlyspring-orm:

<dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-orm</artifactId>    <version>${org.springframework.version}</version></dependency>

This comes with Hibernate and JPA support – such asHibernateTemplate andJpaTemplate – as well as a few additional, persistence related dependencies:spring-jdbc andspring-tx.

The JDBC Data Access library defines theSpring JDBC support as well as theJdbcTemplate, andspring-tx represents the extremely flexibleTransaction Management Abstraction.

4. Spring MVC With Maven

To use the Spring Web and Servlet support, two dependencies need to be included in thepom, again in addition to the core dependencies from above:

<dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-web</artifactId>    <version>${org.springframework.version}</version></dependency><dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-webmvc</artifactId>    <version>${org.springframework.version}</version></dependency>

Thespring-web dependency contains common web specific utilities for both Servlet and Portlet environments, whilespring-webmvc enables the MVC support for Servlet environments.

Sincespring-webmvc hasspring-web as a dependency, explicitly definingspring-web is not required when usingspring-webmvc.

Starting Spring 5.0, for the reactive-stack web framework support, we can add the dependency forSpring WebFlux:

<dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-webflux</artifactId>    <version>${org.springframework.version}</version></dependency>

5. Spring Security With Maven

Security Maven dependencies are discussed in depth in theSpring Security with Maven article.

6. Spring Test With Maven

The Spring Test Framework can be included in the project via the following dependency:

<dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-test</artifactId>    <version>${spring.version}</version>    <scope>test</scope></dependency>

With Spring 5, we can performconcurrent test execution as well.

7. Using Milestones

The release version of Spring is hosted on Maven Central. However, if a project needs to use milestone versions, then a custom Spring repository needs to be added to the pom:

<repositories>    <repository>        <id>repository.springframework.maven.milestone</id>        <name>Spring Framework Maven Milestone Repository</name>        <url>http://repo.spring.io/milestone/</url>    </repository></repositories>

Once this repository has been defined, the project can define dependencies such as:

<dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-core</artifactId>    <version>5.3.0-M1</version></dependency>

8. Using Snapshots

Similar to milestones, snapshots are hosted in a custom repository:

<repositories>    <repository>        <id>repository.springframework.maven.snapshot</id>        <name>Spring Framework Maven Snapshot Repository</name>        <url>http://repo.spring.io/snapshot/</url>    </repository></repositories>

Once the SNAPSHOT repository is enabled in the pom.xml, the following dependencies can be referenced:

<dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-core</artifactId>    <version>4.0.3.BUILD-SNAPSHOT</version></dependency>

As well as – for 5.x:

<dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-core</artifactId>    <version>5.3.0-SNAPSHOT</version></dependency>

9. Conclusion

This article discusses the practical details of usingSpring with Maven. The Maven dependencies presented here are of course some of the major ones, and several others may be worth mentioning and have not yet made the cut. Nevertheless, this should be a good starting point for using Spring in a project.

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

Baeldung Pro comes with both absolutelyNo-Ads as well asfinally withDark Mode, for a clean learning experience:

>> Explore a cleanBaeldung

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

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

Modern software architecture is often broken. Slow deliveryleads to missed opportunities, innovation is stalled due toarchitectural complexities, and engineering resources areexceedingly expensive.

Orkes is the leading workflow orchestration platformbuilt 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 canfocus on building mission critical applications without worryingabout infrastructure maintenance to meet goals and, simply put,taking new products live faster and reducing total cost ofownership.

Try a14-Day FreeTrial of Orkes Conductor today.

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

Modern software architecture is often broken. Slow deliveryleads to missed opportunities, innovation is stalled due toarchitectural complexities, and engineering resources areexceedingly expensive.

Orkes is the leading workflow orchestration platformbuilt 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 canfocus on building mission critical applications without worryingabout infrastructure maintenance to meet goals and, simply put,taking new products live faster and reducing total cost ofownership.

Try a14-DayFree Trial of Orkes Conductor today.

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

TheApache HTTP Client is a very robust library, suitablefor both simple and advanced use cases whentesting HTTPendpoints. Check out our guide covering basic request andresponse handling, as well as security, cookies, timeouts, andmore:

>> Downloadthe eBook

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

Handling concurrency in an application can be a tricky processwith manypotential pitfalls. A solid grasp of thefundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications withourJava 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 astaple of Java development. The basic operations like iterating,filtering, mapping sequences of elements are deceptively simple touse.

But these can also be overused and fall into some commonpitfalls.

Toget a better understanding on how Streams work and howto combine them with other language features, check out our guideto Java Streams:

>> Join Proand 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 theLearn Spring course:

>> CHECK OUTTHE COURSE

Course – LS – NPI – (cat=Spring)
announcement - icon

Get started with Spring Boot and with core Spring,through theLearn Spring course:

>> CHECK OUT THECOURSE

eBook Jackson – NPI EA – 3 (cat = Jackson)
Do JSON right with Jackson - book cover
Do JSON right with Jackson - icon
Do JSON right with Jackson
Download the E-book