Showing posts with label spring. Show all posts
Showing posts with label spring. Show all posts

Tuesday, August 28, 2012

How those Spring @Enable* Annotations work

Spring's Java Config is a great way to configure your application without writing a lot of configuration code.  One reason is those awesome @Enable* annotations that let you magically set up things like Transactions (@EnableTransactionManagement), Spring MVC (@EnableWebMvc) or timed jobs (@EnableScheduling) with a simple class level annotation on your configuration class. These simple statements provide a lot of functionality but their machinations are fairly obscure.  On the one hand, it's great to get so much functionality for so little work, but on the other hand, if you don't understand how something works it makes debugging and problem solving much harder.  I couldn't find any posts or documents that covered how those annotations work so I figured I would write up one based on the research I did while debugging.  I don't work for Spring and I didn't write any of this code so please post any corrections or improvements in the comments and I'll update the post.

Tuesday, May 8, 2012

Pagination with Spring MVC, Spring Data and Java Config

Spring 3.1 has a lot of features for limiting the boiler-plate code you have to write for common functionality.  One great example is pagination.  Getting paged data from a database and presenting it to the user is one of those tasks that everyone seems to reinvent even though it's common functionality that is never specific to your business.  Spring Data provides some facilities to add pagination to your application with a minimal amount of code.  The documentation on this is pretty good and it includes some steps on how to set up both in the data tier and the web tier.  Unfortunately, the documentation is unclear in a few places (see below) and doesn't explain at all how to use a Java Config.  This post tries to fill those gaps.