A Spring Tutorial – This Is Not Your Father’s Spring

I started the REST project on github to explore writing an elegant RESTful Web Service with the latest and greatest Spring had to offer. That was Spring 3.1 and now Spring 3.2, moving towards Spring 4.

Since then, the project has generated a number of articles and tutorials, mainly on Spring Persistence and Spring Security and REST, with the purpose of building, configuring and securing a proper, production ready REST API with Spring.

Bootstrapping a web application with Spring 3.1 and Java based Configuration

The initial steps in bootstrapping a Spring based web application with minimal to no XML configuration.

Building a RESTful Web Service with Spring 3.1 and Java based Configuration

How to set up REST with Spring – the Controller and HTTP response codes, configuration of payload marshalling and content negotiation.

First, Persistence

The Persistence Layer with Spring 3.1 and Hibernate

The focus here is setting up the persistence layer with Spring 3 and Hibernate.

The Persistence Layer with Spring 3.1 and JPA

This article is similar – it discusses the option of setting up persistence with Spring 3 and JPA, with Hibernate as the persistence provider behind JPA.

Simplifying the Data Access Layer with Spring and Java Generics

Before turning to Spring Data to simplify the DAO layer with Spring, a pure Java option is introduced – a single, generified DAO, resulting in elegant data access, with no unnecessary clutter.

The Persistence Layer with Spring Data JPA

This makes the jump into Spring Data JPA, detailing the configuration and setup of Persistence with Spring 3 and Spring Data JPA. This will result in an extremely lightweight DAO layer, with only a few interfaces, with Spring Data actually generating the DAOs and queries automatically.

Transaction configuration with JPA and Spring 3.1

The focus here is transaction configuration with Spring 3 and JPA; transaction management in Spring, best practices, the transaction propagation and common JPA pitfalls are all discussed in detail.

Next, on to the topic of REST

Building a RESTful Web Service with Spring 3.1 and Java based Configuration

Moving to the Web Layer, the article focuses on setting up REST with Spring, the Controller and HTTP response codes, configuration of payload marshalling and content negotiation with both XML and JSON.

RESTful Web Service Discoverability

This continues the discussion on RESTful architecture, focusing on Discoverability of the RESTful service, HATEOAS and practical scenarios driven by tests.

REST Service Discoverability with Spring

Continuing the previous article on Discoverability in a RESTful architecture, the focus here is on the actual implementation of discoverability and satisfying the HATEOAS constraint in Spring 3.

REST Pagination in Spring

This article shows how to implement pagination in a RESTful web service.

ETags for REST with Spring

This article shows how to set up authentication with Spring Security against a RESTful web service.

Testing REST with multiple MIME types

This article will focus on testing a RESTful Service with multiple Media Types/representations.

Exception Handling for REST with Spring 3.2

This article will focus on how to implement Exception Handling with Spring for a REST API. We’ll look at the older solutions available before Spring 3.2 and then at the new Spring 3.2 support.

Finally, we focus on Security

Securing a RESTful Web Service with Spring Security 3.1

Moving over to security, the focus here is on basic Form-based authentication with Spring Security 3.1.

Basic and Digest authentication for a RESTful Service with Spring Security 3.1

This article picks up the other options of securing a REST service with Spring – discussing Basic and Digest authentication and how to configure both protocols for the same URI mapping of the API.

Further Topics to Explore

1. A request limitation mechanism for REST

2. Richer link semantics in REST and a ATOM based REST representation

In the meantime, you can check out the full implementation in the github project.


P.S. If you read this far, you should follow me on Twitter.

, , ,

  • Sunil Nicholas

    Perhaps a stupid question, but I’m trying to build this project and I can’t pull down the test jars. The main source tree compiles fine, but I have compilation issues running rampant in the test source tree. Could this be a Maven issue? Is there anywhere I can pull down the necessary jars manually?

    • Eugen

      What kind of compilation issues are you experiencing? If you have anything specific actually not compiling, please open up an issue in github and I’ll take a look.
      Thanks.
      Eugen.

  • Gbondy

    Do you have an example of a Spring 3.1 bean configuration with annotations when there is a many-to-many relationship. Here is a sample of doing this with xml config

    org.hsqldb.jdbcDriver
    jdbc:hsqldb:hsql://localhost
    sa

    1
    org.hibernate.dialect.HSQLDialect
    true
    create-drop

    I have seen examples for including the properties but I have not found one that shows how to deal with mapping class.

Powered by WordPress. Designed by Woo Themes