First milestone of Spring Data release train Babbage arrived

Engineering | Oliver Drotbohm | June 10, 2013 | ...

I am pleased to announce the first service milestone release for the Spring Data release train named Babbage. It includes the following modules:

The first milestone includes quite a few new features as well as all the bug fixes already released in the service release for Arora.

A quick tour through the release

Most of the changes of this release have made it into Spring Data Commons to build a solid foundation for the next generation of Spring Data projects and make sure that foundation matures fastly. The other modules released in this train station have been adapted to these changes and thus benefit from them as well.

We've upgraded to Querydsl 3.x APIs to accomodate the changes introduced in their major release. The repositories abstraction has added support for ordering ignoring case as well as count…By…(…) projection for derived queries…

This Week in Spring - June 4, 2013

Engineering | Josh Long | June 04, 2013 | ...

Welcome to another installment of This Week in Spring. The SpringOne2GX super early bird registration discount expires on June 10th, 2013, so make your arrangements now to secure the discount. Also, we've got three webinars coming up this month, check out the details below. As usual, we've got a lot to cover, so let's get to it!

  1. I'll be doing a webinar on building effective REST APIs with Spring on June 13th. I'll be introducing Spring's deep support for REST services, starting with Spring MVC and moving up the Richardson Maturity Model to incorporate Spring HATEOAS and, ultimately, Spring Data REST. Along the way we'll look at the REST shell, and other concerns like security through OAuth.
  2. Join Jon Brisbin as he introduces Reactor in a webinar on June 18th. Reactor provides a foundational framework for applications that need high throughput when performing reasonably small chunks of stateless, asynchronous processing.
  3. Join Tony Erksine from Liberty University on June 27th as he instructs us How to talk Spring and Influence People, a pragmatic lesson on soft skills and technology adoption strategies needed to help get other developers in your company excited about,a nd using, new technology -- in this case, with Spring.
  4. If you're in the bay area, be sure to check out JAXConf happening right now in Santa Clara. Admission is free and there are some great speakers there. I will be speaking there tomorrow on Spring 4, and Multi Client Development with Spring, so feel free to drop by if you'd like to talk Spring, Cloud Foundry and big-data.
  5. You probably saw Paul Chapman's awesome posts introducing Spring MVC's support for content negotiation last month and this month he's back with a post on content negotiation using Spring MVC views. Be sure to check both of them out, as they provide solid foundations for dealing with content negotiation in the ever increasing paradigm of REST.
  6. Our friend Petri Kainulainen continues his look at Spring Data SOLR and explains how to add custom repository methods to the implementations above and beyond what Spring Data already provides out of the box. This example is in the context of Spring Data SOLR but the approach is generic and works for all the repository implementations.
  7. RabbitMQ ninja Alvaro Videla has done an amazing job introducing RabbitMQ's power in the latest edition of Developer Magazine.
  8. Every now and then I run into old but cool content, like this project demonstrating how to build a Spring MVC application with Scala. As you might imagine, there's not much difference between Scala and Java, but this is nonetheless an interesting example. Check it out.
  9. I've been knee deep in REST, in preparation for my upcoming webinar, and I stumbled upon a great, albeit older, post by Apache Shiro PMC member and REST-ninja Lez Hazelwood on providing good client feedback on errors with REST in Spring MVC.
  10. Spring HATEOAS lead and Spring Data ninja Oliver Gierke did an amazing talk introducing Spring HATEOAS at Oredev last year and it's available online. Definitely be sure to check it out!
  11. Our pal Nicolas Fränkel is back, this time with a short rant on how to approach modularity in Spring configuration.
  12. JavaBeat has a nice post on how to handle themes in Spring MVC.
  13. The BitwiseOR blog has a nice post on how to setup a simple, working Spring MVC application.
  14. Alexey Zvolinskiy put together a nice, complete-with-code, post on how to use Spring Data JPA to build an application.
  15. David, from The small world for Yiyi blog, has put together a nice post on using PDF, XML and JSON from Spring MVC.
  16. Our pal Johnathan Mark Smith is back, this time with another video introducing how to use Spring's Java configuration

Content Negotiation using Views

Engineering | Paul Chapman | June 03, 2013 | ...

In my previous post I introduced the concept of content negotiation and the three strategies Spring MVC uses to determine the content requested.

In this post I want to extend the concept specifically to supporting multiple views for different content-types using the ContentNegotiatingViewResolver (or CNVR).

Quick Overview

Since we already know how to setup content-negotiation from the previous post, using it to select between multiple views is very straightforward. Simply define a CNVR like this:


    <!--
      // View resolver that delegates to other view resolvers based on the
      // content type…

This Week in Spring - May 28, 2013

Engineering | Josh Long | May 29, 2013 | ...

Welcome to another installment of This Week in Spring. In case you missed it last week, the vast majorty of the SpringOne2GX 2013 agenda has been published, so book now and get the early bird rate on the conference, and airfare! As usual, we've got a lot to cover this week, so let's get to it!

  1. Spring Batch lead Michael Minella announced Spring Batch 2.2.0 RC2. The new release is chalk full of great new features including support for the Spring Batch Java configuration API and a Spring Data GemFire ItemReader and ItemWriter.
  2. Gary Russell just announced Spring Integration 3.0 milestone 2. Be sure to check out the new features and kick the tires!
  3. Join me for a webinar on Building REST-ful Services with Spring - June 13th, 2013. I'll discuss OAUTH, Spring MVC and Spring HATEOAS as it relates to REST.
  4. Rossen Stoyanchev's blogged about the upcoming support for WebSockets in Spring 4 and it looks very compelling!
  5. Gary Russell also just announced the Spring Integration MQTT extension adapter, milestone 1, that makes it easy to work with MQTT - a messaging technology that lends itself to lightweight messaging - from Spring Integration.
  6. Oliver Gierke has written up a great response to the question, how do I return a Spring Data page as JSON on Stack Overflow.
  7. Long-time readers of this roundup will know about Thymeleaf, the templating engine that breathes new life into your web application view templates and that works really well with Spring. The first, stable 2.0.0 version of Thymeleaf-testing has just been released.
  8. Joris Kuipers, on the Trifork blog, has announced a new set of macros for doing form inputs with Spring applications using Freemarker, an alternative - and very powerful - templating engine.
  9. Oleg Tsal-Tsalko put together a talk on the new bits in Spring 4. Nicely done, Oleg!
  10. Johnathan Mark Smith is back at it again, this time with a video on how to do Java configuration with Spring. Check it out!
  11. Maciej Walkowiak put together a great post on how to audit entities using Spring Data MongoDB.
  12. The poorly-named Java2J2EE blog has a great, short-and-sweet post on how to setup JPA and Spring MVC with Spring's Java configuration style. I would however discourage users from calling the lifecycle methods on a Spring FactoryBean directly, and instead choose to dereference the configured result:
    @Bean public EntityManagerFactory emf(){
       LocalContainerEntityManagerFactoryBean lcemfb = ..
       return lcemfb;
    } 
    
    @Bean public PlatformTransactionManager transactionManager(){
      EntityManagerFactory emf = emf().getObject();
      return new JpaTransactionManager( emf );
    } 
    
    

Spring Framework 4.0 M1: WebSocket Support

Engineering | Rossen Stoyanchev | May 23, 2013 | ...

As you may have seen, the first milestone of Spring Framework 4.0 was already announced and with it we've released early WebSocket support. Why WebSocket matters? It enables efficient, two-way communication over the web that is essential in applications where messages need to be exchanged between client (typically browser) and server at high frequency and with low latency. Common examples include trading, games, collaboration, data visualization, and others but the range of scenarios and use cases will grow over time.

WebSocket is a very broad subject! You can watch our “Intro to WebSocket” on…

This Week in Spring - May 21, 2013

Engineering | Josh Long | May 22, 2013 | ...

This Week in Spring

Welcome to another installment of This Week in Spring! We are finally running out of SpringOne2GX video recordings.. this is the last week in Spring that you'll see them, so refer back to the replays page for an index. As usual, we've got a lot to cover so let's get to it!

  1. Spring lead Juergen Hoeller just announced the release of Spring Framework 4.0 M1 and 3.2.3.RELEASE The 3.2.3 update mainly includes updates and fixes related to Java 8 support. The 4.0 milestone, on the other hand, is a look ahead to the many awesome features in Spring 4.0 including support for web sockets, Java EE 7, the @Conditional annotation (in the same vein as the @Profile annotation) and much more, so be sure to check it out!
  2. TcServer 2.9.2 is now available! The release contains security fixes and updates, for more details check out the release notes.
  3. Jennifer Hickey's talk -- Thinking outside the container - Standalone Applications on CloudFoundry has been released in HD on YouTube.
  4. Stephen Bohlen's talk --An Introduction to Spring.NET for Java developers, has been released in HD on YouTube.
  5. InfoQ has done a nice writeup of Spring HATEOAS
  6. Johnathan Mark Smith has put together a nice post on how to use Spring's Java configuration style.
  7. Xavier Padró has put together a nice post on how to communicate within a Spring Web Flow flow
  8. Static.com has announced their Hadoop and Cloud Foundry-powered service. Frankly, it looks really cool and cost-effective as a public platform on which to host applications that need a backoffice Hadoop solution.
  9. I can't believe I missed this! RabbitMQ 3.1.0 is out (slightly old news) and, to introduce it, you should check out this amazing RabbitMQ 3.1.0 in pictures.
  10. The HMKCode blog has a nice post on doing the not-so-well-documented, but common, things with a MyBatis, Spring and jUnit integration.
  11. The Java Code Geeks have put together a nice tutorial on how to process radio buttons in a form in Spring MVC.
  12. Gerry Tan has put together a nice blog on how to bind form date values with Spring MVC.

Spring Framework 4.0 M1 & 3.2.3 available

Engineering | Juergen Hoeller | May 21, 2013 | ...

Dear Spring community,

It's my pleasure to announce the first milestone towards Spring Framework 4.0, delivering a first cut of our work on several key themes:

  • the first wave of Java SE 8 / OpenJDK 8 support (some details following below)
  • initial support for JMS 2.0, JPA 2.1, Bean Validation 1.1, and JSR-236 concurrency (from the EE 7 umbrella)
  • a first cut of our generalized condition mechanism for bean definitions (@Conditional along the lines of @Profile)
  • Spring's WebSocket endpoint model (which Rossen will be introducing in more detail soon)

With respect to Java SE 8, we support OpenJDK 8 build 88+ in several areas of the framework:

  • support for the 1.8 bytecode format in component scanning and subclass generation
  • lambda expressions and method references against Spring callback interfaces
  • JSR-310 Date-Time value types for Spring data binding and formatting
  • initial support for the JDK 8 parameter name discovery mechanism

Note: Spring's Java 8 support is a work in progress and tracking OpenJDK 8 snapshots on their way to the JDK 8 Developer Preview date in September (see http://openjdk.java.net/projects/jdk8/). We expect to release a corresponding Spring Framework 4.0 release candidate around that time, to be presented at SpringOne (September 9-12; see http://springone2gx.com

This Week in Spring - May 14, 2013

Engineering | Josh Long | May 15, 2013 | ...

Welcome to another installment of This Week in Spring! Some rather exciting projects have been announced this week, and if you can believe it, we're almost out of SpringOne 2012 replay content! Good thing the SpringOne 2013 agenda grid is going live very soon, so we'll be able to look ahead. As usual, we've got a lot to cover so let's get to it!

In preparation for the agenda grid going live, a lot of new SpringOne 2013 sessions have been accepted:

  1. Jon Brisbin announced the Reactor project. The Reactor project aims to provide a solid foundation for asynchronous IO-based applications, on top of which it is natural to provide integrations for technologies like Grails and Spring. Reactor already features a good multi-language story with support for Groovy and Java (and, particularly, the upcoming Java 8 release!) Be sure to check this out, especially the comments section if you have questions about how this compares to other asynch technology!
  2. Spring Security lead Rob Winch has been busily enhancing the Spring Security and Spring Security OAuth Java Configuration story. He's got a first cut of the Spring Security OAuth Java Configuration API available, and I'm sure he'd appreciate any feedback on the new DSL, so definitely be sure to check it out! Nice work, Rob!
  3. Webinar on Thursday May 16th with Chris Richardson, author of POJOs in Action, on Decomposing Application for Deployability and Scalabilty. Register Now!
  4. Join Broadleaf Commerce's Andre Azzolini for a Webinar on Tuesday, May 28th as they discuss their Lessons Learned Moving from GWT to SpringMVC.
  5. Paul Chapman introduces some of the diverse support for content negotiation in Spring MVC on the SpringSource blog.
  6. Chris Harris's talk, the Spring Data MongoDB Project, from SpringOne2GX 2012 is now available in HD on YouTube!
  7. Lee Faus's talk, Extreme Makeover - Application Edition, from SpringOne2GX 2012 is now available HD on YouTube!
  8. The JIWHIZ blog, and blogger Yuan Ji, has put together a nice post introducing Spring's Java configuration support.
  9. This post - from blogger Chris Wong in a January post called "JmsTemplate is not evil" - explains some of the subtleties of using Spring's CachingConnectionFactory with a raw ConnectionFactory and then, for extra points, introduces one approach to dramatically speeding up ActiveMQ, in particular.
  10. The HMKcode blog has a nice, exhaustive post introducing how to use the jQuery-file-upload plugin with Spring MVC.
  11. Have you taken a look at HATEOAS yet? HATEOAS is a design pattern, an approach, for building better RESTful web services. Spring HATEOAS makes doing so dead simple atop Spring MVC, and this blog by Geraint Jones introduces Spring HATEAOS very nicely
  12. Blogger Alexey Zvolinskiy answers a common question: how do I bind checkboxes to the model object that's sent back and forth to the server in Spring MVC?
  13. Our friend @baeldung maintains a daily Twitter feed of awesome posts about Spring on StackOverflow, and I think he's dug up some absolutely amazing content. One post answers a question I am frequently asked: how do I enumerate all the Spring MVC @Controller-annotated beans at runtime?
  14. Another great post that I found while trawling through the @SpringAtSO handle was this post, explaining how to propagate request-scoped attributes beyond the thread of the current request. This post applies generally to any situation where a request-scoped attribute needs to propagate beyond its original thread and request.

Reactor - a foundation for asynchronous applications on the JVM

Engineering | Jon Brisbin | May 13, 2013 | ...

We’re pleased to announce that, after a long period of internal incubation, we’re releasing a foundational framework for asynchronous applications on the JVM which we’re calling Reactor. It provides abstractions for Java, Groovy and other JVM languages to make building event and data-driven applications easier. It’s also really fast. On modest hardware, it's possible to process over 15,000,000 events per second with the fastest non-blocking Dispatcher. Other dispatchers are available to provide the developer with a range of choices from thread-pool style, long-running task execution to non…

Content Negotiation using Spring MVC

Engineering | Paul Chapman | May 11, 2013 | ...

There are two ways to generate output using Spring MVC:

  • You can use the RESTful @ResponseBody approach and HTTP message converters, typically to return data-formats like JSON or XML. Programmatic clients, mobile apps and AJAX enabled browsers are the usual clients.
  • Alternatively you may use view resolution. Although views are perfectly capable of generating JSON and XML if you wish (more on that in my next post), views are normally used to generate presentation formats like HTML for a traditional web-application.
  • Actually there is a third possibility - some applications require both, and Spring MVC supports such combinations easily. We will come back to that right at the end.

In either case you'll need to deal with multiple representations (or views) of the same data returned by the controller. Working out which data format to return is called Content Negotiation.

There are three situations where we need to know what type of data-format to send in the HTTP response:

  • HttpMessageConverters: Determine the right converter to use.
  • Request Mappings: Map an incoming HTTP request to different methods that return different formats.
  • View Resolution: Pick the right view to use.

Determining what format the user has requested relies on a ContentNegotationStrategy. There are default implementations available out of the box, but you can also implement your own if you wish.

In this post I want to discuss how to configure and use content negotiation with Spring, mostly in terms of RESTful Controllers using HTTP message converters. In a later post I will show how to setup content negotiation specifically for use with views using Spring's ContentNegotiatingViewResolver

Get the Spring newsletter

Thank you for your interest. Someone will get back to you shortly.

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Tanzu Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all