t**********s 发帖数: 930 | 1 【 以下文字转载自 Programming 讨论区 】
发信人: tennisalways (tennisforever), 信区: Programming
标 题: Spring + Jersey 的 REST API, servlet context 能看到 Spring 的 root application context 里的bean吗?
发信站: BBS 未名空间站 (Fri Oct 9 17:57:56 2015, 美东)
比如这样的 web.xml
contextConfigLocation
/WEB-INF/root-context.xml
org.springframework.web.context.ContextLoaderListener
REST-V1
com.sun.jersey.spi.spring.container.servlet.SpringServlet
contextConfigLocation
/WEB-INF/context-v1.xml
1
REST-V2
com.sun.jersey.spi.spring.container.servlet.SpringServlet
contextConfigLocation
/WEB-INF/context-v2.xml
2
context-v1.xml 和 context-v2.xml 里都必须
/>
否则调用root context 里的bean都会出现 NPE.
可是如果, 那么root context 里的bean就会
生成三次(root-context, context-v1, context-v2)
这是轮子设计的问题吗?还是我哪错了? | F****n 发帖数: 3271 | 2 Spring beans are normally singletons so multiple instances of same contexts
should be OK. (If it is not OK, 99% of time it is because your beans have
some design problem)
There are ways to share runtime contexts, but it increases the complexity of
your apps and makes them more error-prone. Not worth the effort.
application context 里的bean吗?
【在 t**********s 的大作中提到】 : 【 以下文字转载自 Programming 讨论区 】 : 发信人: tennisalways (tennisforever), 信区: Programming : 标 题: Spring + Jersey 的 REST API, servlet context 能看到 Spring 的 root application context 里的bean吗? : 发信站: BBS 未名空间站 (Fri Oct 9 17:57:56 2015, 美东) : 比如这样的 web.xml : : contextConfigLocation : /WEB-INF/root-context.xml : :
|
|