Annotating Java in spring

When writing a complex Java program filled with many interlocking objects, any automation of routine tasks can be a big help. So Java developers using the Java Spring framework should welcome its recent support for annotations, which could take care of many mundane construction and configuration duties.

Spring is an open-source collection of components for developing Java Enterprise Edition- based applications.

Codified in Java Specification Request 250 and added to Version 5 of Java, annotations 'allow you to add metadata to Java source code,' said Rod Johnson, chief executive officer of SpringSource, which sells a commercial version of Spring and corrals the open-source Spring development. Johnson gave a presentation ( on the latest version of Spring, Version 2.5, at the JavaOne Conference, held earlier this year in San Francisco.

Annotations are not merely human-readable metadata. They are a set of extensible keywords, each prefixed by the @ symbol, that class constructors and other Java tools can interpret and process. Annotations have been around since Spring Version 1.2, Johnson said. You could annotate a method or type so that it could be exported to Java Management Extensions, a Java-based tool for managing distributed Java applications.

However, the latest Spring really embraces annotations. 'In Spring 2.5, we've extended annotation support to provide comprehensive support for dependency injection,' Johnson said. Dependency injection, the heart of Spring, allows a program to call an external service without knowing the particulars of where that service is located. The nice thing about these annotations, named @autowired and @resource, is that they can eliminate external configurations of applications. Also, they can be used to change the configuration of a program without changing the source code, Johnson said.

Another new set of annotations supported in 2.5, called meta-annotations, can help developers build a semantic model of the application. Some of these annotations have been standardized, and you can also annotate your own types, through @component.

For more information, go to the Spring 2.5 reference guide, visit

About the Author

Joab Jackson is the senior technology editor for Government Computer News.


  • Records management: Look beyond the NARA mandates

    Pandemic tests electronic records management

    Between the rush enable more virtual collaboration, stalled digitization of archived records and managing records that reside in datasets, records management executives are sorting through new challenges.

  • boy learning at home (Travelpixs/

    Tucson’s community wireless bridges the digital divide

    The city built cell sites at government-owned facilities such as fire departments and libraries that were already connected to Tucson’s existing fiber backbone.

Stay Connected