maven+springMVC+mybatis+junit详细搭建过程(一)
来源:互联网 发布:电子商城评价java源码 编辑:程序博客网 时间:2024/06/05 17:37
springMVC+mybatis框架搭建
首先我们先要弄清搭建项目的一般流程,需要注意哪些方面,想要什么样的效果,自己的功能有哪些?
(假设效果:项目目录结构清晰,能够查询到本地数据库中的内容。。)
1. 工程目录结构整理清楚
在src/main/java文件夹中,新建包cn.springmvc.model(存放javabean),
cn.springmvc.dao(存放spring与mybatis连接接口),
cn.springmvc.service(service接口),
cn.springmvc.service.impl(service接口的实现),
cn.springmvc.controller(存放控制层controller)
在src/main/resource文件夹中,新建包conf(存放配置文件),
mapper(mybatis的mapper文件)
在src/test/java文件夹中,新建包cn.springmvc.test(存放测试文件)
在WEB-INF文件夹下新建jsp文件夹(存放jsp文件)
这样项目结构基本完成了
2. 引入依赖包
打开maven的pom文件,对本次开发所需使用的架包依次导入(maven项目管理的优势)
查找依赖结构有个不错的网站,http://search.maven.org/ 只要输入包名即可查找引来关系
pom.xml(包依赖)
001
<
project
xmlns
=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
002
xsi:schemaLocation
=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
003
<
modelVersion
>4.0.0</
modelVersion
>
004
<
groupId
>eyas.springmvc</
groupId
>
005
<
artifactId
>springmvc</
artifactId
>
006
<
packaging
>war</
packaging
>
007
<
version
>0.0.1-SNAPSHOT</
version
>
008
<
name
>springmvc Maven Webapp</
name
>
009
<
url
>http://maven.apache.org</
url
>
010
<
properties
>
011
<!-- spring版本号 -->
012
<
spring.version
>3.2.4.RELEASE</
spring.version
>
013
<!-- mybatis版本号 -->
014
<
mybatis.version
>3.2.4</
mybatis.version
>
015
<!-- log4j日志文件管理包版本 -->
016
<
slf4j.version
>1.6.6</
slf4j.version
>
017
<
log4j.version
>1.2.9</
log4j.version
>
018
</
properties
>
019
<
dependencies
>
020
<!-- spring核心包 -->
021
<!-- springframe start -->
022
<
dependency
>
023
<
groupId
>org.springframework</
groupId
>
024
<
artifactId
>spring-core</
artifactId
>
025
<
version
>${spring.version}</
version
>
026
</
dependency
>
027
028
<
dependency
>
029
<
groupId
>org.springframework</
groupId
>
030
<
artifactId
>spring-web</
artifactId
>
031
<
version
>${spring.version}</
version
>
032
</
dependency
>
033
034
<
dependency
>
035
<
groupId
>org.springframework</
groupId
>
036
<
artifactId
>spring-oxm</
artifactId
>
037
<
version
>${spring.version}</
version
>
038
</
dependency
>
039
040
<
dependency
>
041
<
groupId
>org.springframework</
groupId
>
042
<
artifactId
>spring-tx</
artifactId
>
043
<
version
>${spring.version}</
version
>
044
</
dependency
>
045
046
<
dependency
>
047
<
groupId
>org.springframework</
groupId
>
048
<
artifactId
>spring-jdbc</
artifactId
>
049
<
version
>${spring.version}</
version
>
050
</
dependency
>
051
052
<
dependency
>
053
<
groupId
>org.springframework</
groupId
>
054
<
artifactId
>spring-webmvc</
artifactId
>
055
<
version
>${spring.version}</
version
>
056
</
dependency
>
057
058
<
dependency
>
059
<
groupId
>org.springframework</
groupId
>
060
<
artifactId
>spring-aop</
artifactId
>
061
<
version
>${spring.version}</
version
>
062
</
dependency
>
063
064
<
dependency
>
065
<
groupId
>org.springframework</
groupId
>
066
<
artifactId
>spring-context-support</
artifactId
>
067
<
version
>${spring.version}</
version
>
068
</
dependency
>
069
070
<
dependency
>
071
<
groupId
>org.springframework</
groupId
>
072
<
artifactId
>spring-aop</
artifactId
>
073
<
version
>${spring.version}</
version
>
074
</
dependency
>
075
076
<
dependency
>
077
<
groupId
>org.springframework</
groupId
>
078
<
artifactId
>spring-test</
artifactId
>
079
<
version
>${spring.version}</
version
>
080
</
dependency
>
081
<!-- springframe end -->
082
083
<!-- mybatis核心包 -->
084
<
dependency
>
085
<
groupId
>org.mybatis</
groupId
>
086
<
artifactId
>mybatis</
artifactId
>
087
<
version
>${mybatis.version}</
version
>
088
</
dependency
>
089
<!-- mybatis/spring包 -->
090
<
dependency
>
091
<
groupId
>org.mybatis</
groupId
>
092
<
artifactId
>mybatis-spring</
artifactId
>
093
<
version
>1.2.2</
version
>
094
</
dependency
>
095
<!-- mysql驱动包 -->
096
<
dependency
>
097
<
groupId
>mysql</
groupId
>
098
<
artifactId
>mysql-connector-java</
artifactId
>
099
<
version
>5.1.29</
version
>
100
</
dependency
>
101
<!-- junit测试包 -->
102
<
dependency
>
103
<
groupId
>junit</
groupId
>
104
<
artifactId
>junit</
artifactId
>
105
<
version
>4.11</
version
>
106
<
scope
>test</
scope
>
107
</
dependency
>
108
<!-- 阿里巴巴数据源包 -->
109
<
dependency
>
110
<
groupId
>com.alibaba</
groupId
>
111
<
artifactId
>druid</
artifactId
>
112
<
version
>1.0.2</
version
>
113
</
dependency
>
114
115
<!-- json数据 -->
116
<
dependency
>
117
<
groupId
>org.codehaus.jackson</
groupId
>
118
<
artifactId
>jackson-mapper-asl</
artifactId
>
119
<
version
>1.9.13</
version
>
120
</
dependency
>
121
122
<!-- 日志文件管理包 -->
123
<!-- log start -->
124
<
dependency
>
125
<
groupId
>log4j</
groupId
>
126
<
artifactId
>log4j</
artifactId
>
127
<
version
>${log4j.version}</
version
>
128
</
dependency
>
129
<
dependency
>
130
<
groupId
>org.slf4j</
groupId
>
131
<
artifactId
>slf4j-api</
artifactId
>
132
<
version
>${slf4j.version}</
version
>
133
</
dependency
>
134
<
dependency
>
135
<
groupId
>org.slf4j</
groupId
>
136
<
artifactId
>slf4j-log4j12</
artifactId
>
137
<
version
>${slf4j.version}</
version
>
138
</
dependency
>
139
<!-- log end -->
140
</
dependencies
>
141
<
build
>
142
<
finalName
>springmvc</
finalName
>
143
</
build
>
144
</
project
>
- maven+springMVC+mybatis+junit详细搭建过程(一)
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- maven+springMVC+mybatis+junit详细搭建过程
- 黑马程序员_单例设计模式
- ACM知识点
- 三极管基极偏置电阻
- AOJ-AHU-OJ-595 撒哈拉大冒险(栈)
- win7 32位下VC++6.0的安装以及打不开文件的教程
- maven+springMVC+mybatis+junit详细搭建过程(一)
- 30 图像尺度空间
- 直接播放H264视频流的方法或工具
- 使用第三方 'Could not find class 'net.htmlparser.jericho.Source' 错误修复 红色感叹号
- css过滤器的使用(2)!
- php 邮件发送问题
- VMware-workstation-11 + Ubuntu 14.04.2
- maven+springMVC+mybatis+junit详细搭建过程(二)
- 配置多个Tomcat