[英]Initialize Spring beans packaged inside a jar file
在web-app中,我們為spring定義上下文配置位置以初始化所有這樣的bean
<!-- Spring Application Configuration -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/ctx-*.xml</param-value>
</context-param>
<listener>
<description>Spring Context Listener</description>
<display-name>SpringContextListener</display-name>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
我試圖找出,如果有可能在jar文件(包含所有的spring bean)中做到這一點,我沒有web.xml?
你可以使用前綴'classpath:'
classpath:ctx-*.xml
見http://static.springsource.org/spring/docs/2.5.6/reference/resources.html#resources-app-ctx
您可以添加委派級別put /WEB-INF/spring/my-aggregator-context.xml
這是一個占位符xml文件,它執行“import classpath:ctx * -xml”
如果您在許多jar中有多個appContext.xml,並且您想要包含所有內容,那么您甚至可以說classpath *:appContext.xml
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.