0 0

使用springmvc + springsecurity + apache-cxf 时,配置文件加载问题.3

这几种技术或框架的bean都希望由spring管理.

例如:如果写成这样,就是由mvc的servlet加载,其他两部分 springsecurity + apache-cxf 就用不了.
	<servlet>
		<servlet-name>SpringServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring/applicationContext.xml</param-value>
		</init-param>
	</servlet>


现在能单独把 cxf 的提取出来,因为只用来创建 WebService 用.
写法如下:
  <servlet>
    <servlet-name>SpringMvcServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>SpringMvcServlet</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  
	<servlet>
		<servlet-name>cxf</servlet-name>
    	<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    	<load-on-startup>2</load-on-startup>
	</servlet>
  <servlet-mapping>
    <servlet-name>cxf</servlet-name>
    <url-pattern>/service/*</url-pattern>
  </servlet-mapping>
  <!-- 额外加载 cxf-service.xml ,配置 service -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/cxf/service/cxf-service.xml</param-value>
  </context-param>
  <listener>
    <listener-class>  
           org.springframework.web.context.ContextLoaderListener  
        </listener-class>
  </listener>



想按照这种方式,将spring security 的配置提取出,比较麻烦,
因为希望使用相同的DAO bean.这样有些东西就需要加载两次.

不知道其他人没有没这个问题? 如何有,怎么解决的...
请指教.

   



难道各位都加载两次?

为啥木有人回答呢,为啥呢..........
在DataSource那里自己管理,不用spring bean管理.这样只是 DAO 和 Serivice 层创建两次,也可以接受.

求其他处理方法..
2012年3月21日 19:08

1个答案 按时间排序 按投票排序

0 0

http://kyfxbl.iteye.com/blog/1432920希望会对你有帮助

2014年6月03日 16:47

相关推荐

Global site tag (gtag.js) - Google Analytics