Eclipse下SSM项目的搭建

时间:2019-06-18
本文章向大家介绍Eclipse下SSM项目的搭建,主要包括Eclipse下SSM项目的搭建使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

本文示例在如下环境下搭建一个Maven+Druid+SSM+PageHelper以及Mybatis Generator反向生成代码的项目

一.开发环境:

系统:Windows7-旗舰版

工具:Eclipse MARSNavicat Premium 12

JDK:1.8.0_121

Tomcat:8.0.43

MySQL :5.6.5-m8

二.搭建流程:

一.环境准备

1.1 配置JDK

在window--》Preferences下搜索Java,选择本地对应的JDK安装目录,点击添加完成:

配置完开发环境JDK后,需要修改项目默认的编译环境:

1.2 配置Tomcat

在window--》Preferences下搜索Server,选择自己本地对应的Tomcat版本及JRE环境,点击添加完成:

添加完成之后,配置Tomcat,如图所示,分别对应项目发布路径、自动部署、发布超时时间、访问端口等配置

 1.3 配置Maven

在window--》Preferences下搜索Maven,选择本地Maven安装路径:

添加Maven后配置自定义属性,替换自己的Maven settings配置文件及Maven仓库:

二.创建项目

2.1 使用Eclipse创建Maven项目:

2.2 项目创建完成后,根据自己习惯的包名结构创建对应的目录,项目结构如图所示:

 

三.配置pom.xml依赖

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4   <modelVersion>4.0.0</modelVersion>
  5   <groupId>com</groupId>
  6   <artifactId>mySpringMVC</artifactId>
  7   <packaging>war</packaging>
  8   <version>0.0.1-SNAPSHOT</version>
  9   <name>mySpringMVC Maven Webapp</name>
 10   <url>http://maven.apache.org</url>
 11   
 12   <properties>
 13        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 14        
 15        <jdk.version>1.8</jdk.version>
 16      <spring.version>4.1.9.RELEASE</spring.version>
 17      <mysql-connector>8.0.13</mysql-connector>
 18      <druid.version>1.0.18</druid.version>
 19      <mybatis.version>3.2.8</mybatis.version>
 20      <mybatis-spring.version>1.2.3</mybatis-spring.version>
 21      <mybatis-generator.version>1.3.5</mybatis-generator.version>
 22   </properties>
 23   
 24   <!-- 定义Maven项目依赖 -->
 25   <dependencies>
 26         <!-- Junit 测试依赖 -->
 27         <dependency>
 28             <groupId>junit</groupId>
 29             <artifactId>junit</artifactId>
 30             <version>3.8.1</version>
 31             <!-- 表示开发的时候引入,发布的时候不会加载此包 -->  
 32             <scope>test</scope>
 33         </dependency>
 34     
 35         <!-- spring核心依赖 -->
 36         <dependency>
 37             <groupId>org.springframework</groupId>
 38             <artifactId>spring-core</artifactId>
 39             <version>${spring.version}</version>
 40         </dependency>
 41         
 42         <!-- springWeb依赖 -->
 43         <dependency>
 44             <groupId>org.springframework</groupId>
 45             <artifactId>spring-web</artifactId>
 46             <version>${spring.version}</version>
 47         </dependency>
 48         
 49         <!-- springMVC依赖 -->
 50         <dependency>
 51             <groupId>org.springframework</groupId>
 52             <artifactId>spring-webmvc</artifactId>
 53             <version>${spring.version}</version>
 54         </dependency>
 55     
 56         <!-- springJDBC依赖 -->
 57         <dependency>
 58             <groupId>org.springframework</groupId>
 59             <artifactId>spring-jdbc</artifactId>
 60             <version>${spring.version}</version>
 61         </dependency>
 62     
 63         <!-- spring上下文依赖 -->
 64         <dependency>
 65             <groupId>org.springframework</groupId>
 66             <artifactId>spring-context</artifactId>
 67             <version>${spring.version}</version>
 68         </dependency>
 69     
 70         <!-- spring上下文支持依赖 -->
 71         <dependency>
 72             <groupId>org.springframework</groupId>
 73             <artifactId>spring-context-support</artifactId>
 74             <version>${spring.version}</version>
 75         </dependency>
 76     
 77         <!-- springAOP依赖 -->
 78         <dependency>
 79             <groupId>org.springframework</groupId>
 80             <artifactId>spring-aop</artifactId>
 81             <version>${spring.version}</version>
 82         </dependency>
 83     
 84         <!-- spring测试依赖 -->
 85         <dependency>
 86             <groupId>org.springframework</groupId>
 87             <artifactId>spring-test</artifactId>
 88             <version>${spring.version}</version>
 89         </dependency>
 90     
 91         <!-- spring OXM依赖 -->
 92         <dependency>
 93             <groupId>org.springframework</groupId>
 94             <artifactId>spring-oxm</artifactId>
 95             <version>${spring.version}</version>
 96         </dependency>
 97         
 98         <!-- spring 事务依赖 -->
 99         <dependency>
100             <groupId>org.springframework</groupId>
101             <artifactId>spring-tx</artifactId>
102             <version>${spring.version}</version>
103         </dependency>
104     
105         <!-- Servlet依赖 -->
106         <dependency>
107             <groupId>javax.servlet</groupId>
108             <artifactId>javax.servlet-api</artifactId>
109             <version>3.0.1</version>
110             <scope>provided</scope>
111         </dependency>
112         
113         <dependency>
114             <groupId>javax.servlet</groupId>
115             <artifactId>jstl</artifactId>
116             <version>1.1.2</version>
117             <scope>provided</scope>
118         </dependency>
119         
120         <!-- jsp依赖 -->
121         <dependency>
122             <groupId>javax.servlet.jsp</groupId>
123             <artifactId>javax.servlet.jsp-api</artifactId>
124             <version>2.3.1</version>
125             <scope>provided</scope>
126         </dependency>
127         
128         <!-- jackson 依赖 -->
129         <dependency>
130             <groupId>org.codehaus.jackson</groupId>
131             <artifactId>jackson-jaxrs</artifactId>
132             <version>1.9.11</version>
133         </dependency>
134     
135         <!-- commons 依赖 -->
136         <dependency>
137             <groupId>org.apache.commons</groupId>
138             <artifactId>commons-lang3</artifactId>
139             <version>3.3.2</version>
140         </dependency>
141         
142         <dependency>
143             <groupId>commons-io</groupId>
144             <artifactId>commons-io</artifactId>
145             <version>2.4</version>
146         </dependency>
147         
148         <dependency>
149             <groupId>org.apache.commons</groupId>
150             <artifactId>commons-collections4</artifactId>
151             <version>4.0</version>
152         </dependency>
153         
154         <dependency>
155             <groupId>commons-logging</groupId>
156             <artifactId>commons-logging</artifactId>
157             <version>1.1.3</version>
158         </dependency>
159         
160         <dependency>
161             <groupId>commons-codec</groupId>
162             <artifactId>commons-codec</artifactId>
163             <version>1.8</version>
164         </dependency>
165         <dependency>
166             <groupId>commons-beanutils</groupId>
167             <artifactId>commons-beanutils</artifactId>
168             <version>1.8.3</version>
169         </dependency>
170         
171         <dependency>
172             <groupId>commons-chain</groupId>
173             <artifactId>commons-chain</artifactId>
174             <version>1.2</version>
175         </dependency>
176         
177         <dependency>
178             <groupId>commons-fileupload</groupId>
179             <artifactId>commons-fileupload</artifactId>
180             <version>1.3.1</version>
181         </dependency>
182         
183         <dependency>
184             <groupId>org.apache.commons</groupId>
185             <artifactId>commons-math3</artifactId>
186             <version>3.3</version>
187         </dependency>
188         
189         <dependency>
190             <groupId>org.apache.commons</groupId>
191             <artifactId>commons-pool2</artifactId>
192             <version>2.2</version>
193         </dependency>
194         
195         <dependency>
196             <groupId>org.apache.commons</groupId>
197             <artifactId>commons-digester3</artifactId>
198             <version>3.2</version>
199         </dependency>
200         
201         <dependency>
202             <groupId>commons-net</groupId>
203             <artifactId>commons-net</artifactId>
204             <version>3.3</version>
205         </dependency>
206         
207         <dependency>
208             <groupId>commons-dbutils</groupId>
209             <artifactId>commons-dbutils</artifactId>
210             <version>1.5</version>
211         </dependency>
212         
213         <dependency>
214             <groupId>org.apache.commons</groupId>
215             <artifactId>commons-email</artifactId>
216             <version>1.3.3</version>
217         </dependency>
218         
219         <dependency>
220             <groupId>commons-dbcp</groupId>
221             <artifactId>commons-dbcp</artifactId>
222             <version>1.4</version>
223         </dependency>
224     
225         <!-- jstl依赖 -->
226         <dependency>
227             <groupId>jstl</groupId>
228             <artifactId>jstl</artifactId>
229             <version>1.2</version>
230         </dependency>
231     
232         <!-- 标签库依赖 -->
233         <dependency>
234             <groupId>taglibs</groupId>
235             <artifactId>standard</artifactId>
236             <version>1.1.2</version>
237         </dependency>
238         
239         <!-- 日志相关 -->
240         <dependency>
241             <groupId>log4j</groupId>
242             <artifactId>log4j</artifactId>
243             <version>1.2.16</version>
244         </dependency>
245     
246         <dependency>
247             <groupId>org.slf4j</groupId>
248             <artifactId>slf4j-api</artifactId>
249             <version>1.7.5</version>
250         </dependency>
251     
252         <!-- 阿里连接池依赖 -->
253         <dependency>
254              <groupId>com.alibaba</groupId>
255              <artifactId>druid</artifactId>
256              <version>${druid.version}</version>
257         </dependency>
258     
259         <!-- 阿里fastjson						

原文地址:https://www.cnblogs.com/ljhblogs/p/11039255.html