Maven 3 has a new DSL formats for its POM. Is there a similar sort of format for Spring applicationcontext.xml files?

StackOverflow https://stackoverflow.com/questions/3816077

  •  26-09-2019
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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>.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top