Spring 3.1 M2: Spring MVC Enhancements

Engineering | Rossen Stoyanchev | June 13, 2011 | ...

This post focuses on what's new for Spring MVC in Spring 3.1 M2. Here are the topics:

  • Code-based equivalent for the MVC namespace.
  • Customizable @MVC processing.
  • Programming model improvements.

A brief reminder that the features discussed here are in action at the Greenhouse project.

Code-based Configuration For Spring MVC

As Chris pointed out in his blog post last Friday, XML namespaces cut down configuration dramatically but also reduce transparency and sometimes flexibility. This holds true for the MVC namespace, which supports a number of customizations but not everything that's available. That means you are either able to use it or otherwise leave it. We believe code-based configuration has a solution for that and a path from simple to advanced.

Let's begin with this simple, familiar snippet:


<mvc:annotation-driven />

Although not required for using annotated controllers, <mvc:annotation-driven> does a number of useful things -- it detects the presence of a JSR-303 (Bean Validation) implementation and configures data binding with it, it adds a JSON message converter if Jackson JSON library is available, and a few other things that can save quite a bit of configuration.

Now let's match that with code-based configuration:


@Configuration
@EnableWebMvc
public class WebConfig {
}

Here @EnableWebMvc imports an @Configuration class that matches the goodness of <mvc:annotation-driven>. As simple as that.

The next step is to use an attribute in <mvc:annotation-driven> perhaps to provide a FormattingConversionService, or to add a sub-element perhaps configuring message converters, or to use other MVC namespace elements like <mvc:interceptors>, <mvc:resources>, etc.

Let's see how to do all of that in code-based configuration:


@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addFormatters(FormatterRegistry registry) {
        // register converters and formatters...
    }

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        // add message converters...
    }

    @Override
    public void configureInterceptors(InterceptorConfigurer configurer) {
        configurer.addInterceptor(new…

SpringSource Tool Suite 2.7.0.M2 Released

Releases | Martin Lippert | June 13, 2011 | ...

Dear Spring Community,

I'm pleased to announce that we just released the second milestone build for the next release of the SpringSource Tool Suite (STS).

This milestone brings mostly new features for the Cloud Foundry support and Groovy&Grails developers, including:

  • Improved Cloud Foundry support
  • Support for Grails 1.4
  • Grails aware Rename Type Refactoring
  • Improved content assist for GSPs
  • Improved Gradle support

More details can be found in the New and Noteworthy for 2.7.0.M2 document. Detailed installation instructions are also available, please look at the installation from the milestone update sites.

As always downloads are available from the STS download page, check "Other Downloads".

The release is planned for the beginning of July…

Spring 3.1 M2: Configuration Enhancements

Engineering | Chris Beams | June 10, 2011 | ...

As Juergen mentioned in his post yesterday, and as I've mentioned in my previous posts on 3.1 M1, one of the major themes of Spring 3.1 is completing our vision for code-based configuration in Spring. We think a modern enterprise Java application should have a choice between Java and XML as first class options for its configuration. In this post we'll see how Spring 3.1 M2 helps make this a reality.

Note that although Java-based configuration has been available since Spring 3.0, with this release it is now on par with many more of the XML-based features that have been developed over the…

Spring Framework 3.1 M2 released

Engineering | Juergen Hoeller | June 09, 2011 | ...

Spring Framework 3.1 M2 has been released this week, marking the end of the 3.1 milestone phase. We are moving on to the release candidate phase now, preparing for a feature-complete RC1 in July and a GA release in September.

3.1 M2 completes the work on several major themes started in 3.1 M1 back in February:

  • We've stabilized our environment abstraction and the environment profile mechanism. If you haven't given it a try already, now is a great time to check it out!

  • Our Java-based application configuration approach has changed from the @Feature approach in M1 to @Enable* annotations on regular @Configuration classes in M2.

  • The cache abstraction has been revised for delivering a minimal cache interaction SPI. Our declarative caching solution (@Cacheable etc) keeps sitting on top of it.

This week in Spring: June 7th, 2011

Engineering | Josh Long | June 08, 2011 | ...

Welcome back to another exciting roundup! This week's been a blur. Honestly. So much new stuff happening, all after the rush of excitement that was the S2G Forums in Europe last week. Leave's a guy breathless, but excited. Read on!

  1. Mark Fisher and Ramnivas Laddad's webinar Spring From Zero to Cloud in 60 Minutes is available online.
    This webinar is a breakneck-speed tour of some of the Spring, Spring Roo and Grails support on CloudFoundry. Check it out!
    Before you start watching, however, quickly signup at CloudFoundry.com to get access to the public, free-beta cloud service. If you want to checkout the code and learn more, check out CloudFoundry.org.

  2. Jeremy Grelle, Spring BlazeDS lead and general "Spring web dude," has announced the first release candidate of the Spring Flex project. The Spring Flex project integrates the Flex BlazeDS middleware with Spring, providing a dead-simple way to expose Spring beans in a way that can be consumed by Flex or Adobe AIR web and desktop clients. The Spring Flex project also provides integration with Spring Security and provides tight-knit support for server-side push based messaging, entirely in-BlazeDS, or through JMS or Spring Integration. Ever wanted to notify users logged into an application that something's happened on the server side (Twitter message, new AMQP message, new XMPP message, whatever..)? Spring Flex makes it easy.
  3. Martin Lippert, SpringSource Tool Suite team lead, has given an interview about the latest and greatest in SpringSource Tool Suite 2.6. He talks about many of the highlights, including STS 2.6's reworked Spring Webflow visualization, Java configuration support, the cloud, agent-based reloading, and what's next. Check it out!
  4. Thomas Risberg has announced the Spring Data Document support for MongoDB, release 1.0.0.M3. The changes and new features in Spring Data Document 1.0.0.M3 includes much improved mapping and conversion support. The MappingMongoConverter is now the default converter used by the MongoTemplate and the SimpleMongoConverter has been deprecated and will be removed. The concept of a default collection name has also been removed and all operations of the MongoTemplate are based on the collection name used for the entity class that is the target of the operation. The collection name used for an entity class defaults to the classname starting with a lower-case letter but it can be customized using the @Document annotation. See the changelog for more details.
  5. Milestone 5 of Virgo 3.0.0 is available for download. This is an important milestone which adds significant functional enhancements, upgrades several dependencies to their latest levels including Spring 3.0.5, Tomcat 7.0.12, and Servlet 3.0, and fixes a number of bugs. Full details are available in the release notes. The Virgo Web Server from EclipseRT is a completely module-based Java application server that is designed to run enterprise Java applications and Spring-powered applications with a high degree of flexibility and reliability. It offers a simple yet comprehensive platform to develop, deploy, and service enterprise Java applications.
  6. Marius Bogoevici - a Spring Integration committer - has written a fantastic post on the options for using a JPA EntityManager in JBoss AS with Spring. The main thrust of the post is that the application server automatically creates an EntityManager, by default, so there may be no need to recreate one in Spring - you can simply inject the existing reference. This approach is specifically to get around the presumptuous behavior of a full blown application server. If you'd like to run in Tomcat, then Spring's the easiest way to configure a JPA EntityManager. Marius also explains how to let Spring run the show entirely by disabling the application server behavior. This has the plural benefits of usually being more performant, and of keeping configuration with the application itself, not the server.
  7. Matt Raible has posted a follow up to his blog posts and screencasts on security in web applications. Previously, he demonstrated how to use Spring Security, Apache Shiro, and Java EE security in a pseudo identical fashion to secure a web application, highlighting the differences as appropriate. This follow up article talks about all three technologies and provides a comparison for enabling programmatic login when integrated in a Spring MVC application. The Spring Security support has been around for a long time and works in numerous containers (not Just Java EE 6 compliant containers) with no fuss. Nice!
  8. Have you dabbled in other JVM based languages? Have you taken a look at Scala? Well at the recent Scala Days conference in Palo Alto, CA, the Cloud Foundry team announced new Scala support on CloudFoundry.com!
  9. If you were at the S2G Forums in London last week, you would've received a free copy of the Open Source Journal - a printed (and freely downloadable .PDF) magazine. This publication has done a bang up job covering some of the Spring framework technologies. It's available from the publisher's web site as a free download. Check out the first and second issues here. The second issue, for example, has a great introduction to Spring.NET (including the new code configuration - the .NET analog to Spring Java's Java configuration), a look at Spring.NET's RestTemplate (a nice analog to Spring Java's RestTemplate), and a look at using Spring Integration (and Spring Web Services) to make short work of exposing web services. This format is especially ideal if you have a .PDF-capable e-reader or tablet PC. Check it out!

Spring 3.1.0 M2 Released

Releases | Chris Beams | June 08, 2011 | ...

The second and final milestone of Spring 3.1 is now available from our http://maven.springframework.org/milestone Maven repository or for direct download from our community download page. This release includes new features such as:

  • Code equivalents for Spring's XML namespaces
  • Builder-style APIs for code-based Hibernate configuration
  • TestContext framework support for @Configuration classes and bean definition profiles
  • Support for injection against non-standard JavaBeans setters
  • Support for Servlet 3 code-based configuration of Servlet container
  • Support for Servlet 3 MultipartResolver
  • JPA EntityManagerFactory bootstrapping without persistence.xml
  • New HandlerMethod-based Support Classes For Annotated Controller Processing
  • Consumes and Produces @RequestMapping Conditions
  • Working With URI Template Variables In Controller Methods
  • Validation For @RequestBody Method Arguments
See the New Features and Enhancements in Spring 3.1 section of the reference documentation for more information

Stay tuned to the SpringSource Blog over the coming week for a series of posts covering what's new in 3.1.0.M2.

Download | Documentation | Javadoc API | Change Log | JIRA

Don't forget that Spring users can ask questions in the community forum and identify issues in JIRA as well.

Countdown to Grails 2.0: Unit testing

Engineering | Peter Ledbrook | June 07, 2011 | ...

The first milestone of Grails 1.4 (now 2.0) has now been released and we are on the last stages of the journey towards 1.4 2.0 final. As we approach that point, I will be writing a series of blog posts that cover the various new features and changes that the 1.4 2.0 version brings. I'll be starting with the new testing support.

Since the beginning, Grails has provided three levels of testing support for developers: unit, integration, and functional. Unit tests had and still have the benefit of running independently of Grails, but they typically required a fair bit of extra work in the form of…

Spring BlazeDS Integration 1.5.0.RC1 Released

Releases | Jeremy Grelle | June 02, 2011 | ...

Dear Spring Community,

I'm pleased to announce that the 1.5.0.RC1 release candidate of Spring BlazeDS Integration, the open source solution for building Spring-powered RIAs with Adobe Flex, is now available.

Download | Reference Documentation | JavaDocs | Changelog

This release is largely focused on stabilization of the new features introduced in the previous milestones. Significant attention has been paid to maturing the refactored Spring Security 3 support and the Hibernate AMF serialization support. New annotations such as @AmfIgnore and @AmfCreator allow deeper customization of the AMF conversion process, and this enhanced AMF support has now been made generally available for application to any object type, not just those persisted with Hibernate.

As always, I encourage anyone interested to get involved by trying out the release and giving us feedback in the community forum and Jira, as we are expecting only a short break before the release of 1.5.0.GA. We continually get great feedback from people having success with Spring BlazeDS Integration in their projects, and we look forward to hearing more about your experiences.


Jeremy Grelle
Spring Flex Lead

Spring Data Document with MongoDB Support 1.0.0.M3 Released

Releases | Thomas Risberg | June 02, 2011 | ...

Dear Spring Community,

I am pleased to announce that the Milestone 3 release of the Spring Data Document 1.0 project with MongoDB support is now available! The primary goal of the Spring Data project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.

The MongoDB module provides integration with the MongoDB document database.

Downloads | JavaDocs | Reference Documentation | Changelog

To learn more about the project, visit the Spring Data MongoDB Page.

The changes…

A Simple Groovy DSL for building RabbitMQ AMQP Applications

Engineering | Jon Brisbin | June 01, 2011 | ...

Asynchronous applications can sometimes be a challenge while you're developing them since you usually need two separate components to see the full message publication and consumption lifecycle. It often happens that you write a consumer that can dump messages to System.out or your log file, just so you can make sure your publisher is doing the right thing. It would be really handy if you could mock the message publication and consumption interaction in a single component so you could actually see what's going on.

The RabbitMQ Groovy DSL aims to help with this by providing a very concise and…

Get the Spring newsletter

Stay connected with the Spring newsletter

Subscribe

Get ahead

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

Learn more

Get support

Tanzu Spring 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