1、hibernate 相关依赖,(5.2.12.Final)
1-1:hibernate-core:
1-2: hibernate-c3p0(数据库连接池)
1-3: hibernate-ehcache
1-4: mysql-connector-java(5.1.44)
注意:为了统一版本,方便以后维护,可把统一版本写成可编辑的
相关依赖如下:
<!--统一的版本,可编辑的 -->
<properties>
<hibernate.version>5.2.12.Final</hibernate.version>
<mysql.version>5.1.44</mysql.version>
</properties>
<!-- 1、hibernate相关(5.2.12.Final) -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
2 spring相关(5.0.1.RELEASE)
2-1 spring-context
2-2:spring-orm
2-3: spring-web
2-4: spring-aspects
<properties>
<spring.version>5.0.1.RELEASE</spring.version>
</properties>
<!-- 2、spring相关(5.0.1.RELEASE) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
3 struts2相关(2.5.13)
3-1:struts2-core
3-2:struts2-spring-plugin
3-3:struts2与spring集成的插件
将action配置到spring中,struts的action标签的class属性填写spring中bean的名字或id
<!-- 3、struts2相关(2.5.13) -->
<properties>
<struts2.version>2.5.13</struts2.version>
</properties>
<dependencies>
<!-- 1、hibernate相关(5.2.12.Final) -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
4、log4j2(2.9.1)
log4j-core
log4j-api
log4j-web
不建议使用
<properties>
<slf4j.version>1.7.7</slf4j.version>
<log4j.version>2.9.1</log4j.version>
<disruptor.version>3.2.0</disruptor.version>
</properties>
<!-- 4、log配置 -->
<!-- log配置:Log4j2 + Slf4j -->
<!-- slf4j核心包 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<!--用于与slf4j保持桥接 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<!--核心log4j2jar包 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<!--web工程需要包含log4j-web,非web工程不需要 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>${log4j.version}</version>
<scope>runtime</scope>
</dependency>
<!--需要使用log4j2的AsyncLogger需要包含disruptor -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>${disruptor.version}</version>
</dependency>
5、其他:
junit(4.12)
javax.servlet-api(4.0.0):
<properties>
<junit.version>4.12</junit.version>
<servlet.version>4.0.0</servlet.version>
</properties>
<!-- 5、other -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
6、 jstl
jstl(1.2)
standard(1.1.2):
<properties>
<jstl.version>1.2</jstl.version>
<standard.version>1.1.2</standard.version>
</properties>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>${standard.version}</version>
</dependency>
7、jsp自定义标签依赖(必须与tomcat的版本一致)
tomcat-jsp-api
<properties>
<tomcat-jsp-api.version>8.0.47</tomcat-jsp-api.version>
</properties>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jsp-api</artifactId>
<version>${tomcat-jsp-api.version}</version>
</dependency>
备注:如果不知道自己Tomcat版本的,可以查看以下tomcate版本步骤:
7-1、找到Window----->Preferences,输入:Servers,找到Runtime Environments
7-2:选择Tomcat,进行编辑
7-3:查看自己的版本。我的是8.0.47
8、配置与jsk版本,我这里 是1.8,其实第一步就是配置maven-compiler-plugin插件
<plugins>
<!--第一步就是配置maven-compiler-plugin插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
9、配置web.xml:
注:3.0对应jdk1.7, 3.1对应jdk 1.8
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
10、选择项目,右键Propetites ------>Maven------Project Facets
把Dynamic Web Module 改为 3.1
Java 改为 1.8
好了,以上就是ssh项目整合的第一步!