views:

40

answers:

2

In Maven 3 there are new DSL replacements for the POMs. See: http://polyglot.sonatype.org/groovy.html for the wonderfully terse syntax.

Is there something similar that can be used for Spring applicationcontext.xml files?

+2  A: 

In Spring 3 you may use Java-based container configuration, see 3.11 Java-based container configuration. It also plays well with autodetection of components. To use these features instead of applicationContext.xml, add the following to web.xml:

<context-param>
    <param-name>contextClass</param-name>
    <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        ... package and class names to use for configuration ...
    </param-value>
</context-param>

You may also configure DispatcherServlet in the same way - with <init-param> instead of <context-param>.

axtavt
And you can also write this configuration in groovy, so it will much terse.
uthark
+1  A: 

Have a look at the Grails Spring BeanBuilder, that provides a "groovy" way for the definition and configuration of Spring beans: http://www.grails.org/Spring+Bean+Builder

codescape