现在的位置: 首页 > 综合 > 正文

Spring+Struts+Hibernate+Maven

2014年09月05日 ⁄ 综合 ⁄ 共 782字 ⁄ 字号 评论关闭

1.Maven

1.1 pom中配置好需要引入的Jar,Maven会自动从Maven仓库下载,如果下载失败,pom.xml文件会报错,需要在本地Maven仓库中找到对应的Jar,把已下载到的文件删除。之后在项目上右键Maven->Update Dependencies,一般都可以解决啦

1.2  src/main/resources 下的文件,相当于在根目录下,XML中使用时直接 classpath:xxx.xml


2.Spring

  1. 在pom.xml中加入Jar包
  2. 建立Struts配置文件
  3. 在web.xml 中加入spring监听器
<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

3.Stuts

  1. 在pom.xml中加入Jar包,注意与Hibernate整合需要排除struts2-core中的 javassist
  2. 建立Struts配置文件
  3. 在web.xml 中加入Struts的filter、fileter-mapping

4.Spring与Struts整合

 不需要特殊配置,只需要在pom.xml中加入

<dependency>
          <groupId>org.apache.struts</groupId>
          <artifactId>struts2-spring-plugin</artifactId>
          <version>2.3.4.1</version>
</dependency>


不需要在Spring中配置加入Action包的扫描,只设置DAO和Service,如下

	<!-- 自动扫描dao和service包(自动注入) -->
	<context:component-scan base-package="xx.dao,xx.service" />

抱歉!评论已关闭.