一、配置maven环境
1.下载maven:下载链接
2.下载完成解压压缩包并创建本地仓库文件夹
3.打开解压缩文件,配置本地仓库路径
4.配置maven环境变量
5.在cmd中查看maven是否配置正确
在cmd中输入mvn -v命令查看
二、在intellij idea中配置maven
打开-file-settings
三、新建maven javaweb项目
1.打开-file-new-project
next
next
添加的配置为 archetypecatalog=internal
next
点击finish完成
生成项目框架后,在 src/main 下创建 java目录。项目的工程结构如图。
四、配置项目框架文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
<?xml version= "1.0" encoding= "utf-8" ?>
<project xmlns= "http://maven.apache.org/pom/4.0.0"
<modelversion> 4.0 . 0 </modelversion>
<groupid>com.cwp</groupid>
<artifactid>ssmdemo01</artifactid>
<version> 1.0 -snapshot</version>
<url>http: //maven.apache.org</url>
<properties>
<project.build.sourceencoding>utf- 8 </project.build.sourceencoding>
<project.reporting.outputencoding>utf- 8 </project.reporting.outputencoding>
<!-- spring版本号 -->
<spring.version> 4.2 . 5 .release</spring.version>
<!-- mybatis版本号 -->
<mybatis.version> 3.2 . 8 </mybatis.version>
<!-- mysql驱动版本号 -->
<mysql-driver.version> 5.1 . 29 </mysql-driver.version>
<!-- log4j日志包版本号 -->
<slf4j.version> 1.7 . 18 </slf4j.version>
<log4j.version> 1.2 . 17 </log4j.version>
</properties>
<dependencies>
<!-- 添加jstl依赖 -->
<dependency>
<groupid>jstl</groupid>
<artifactid>jstl</artifactid>
<version> 1.2 </version>
</dependency>
<dependency>
<groupid>javax</groupid>
<artifactid>javaee-api</artifactid>
<version> 7.0 </version>
</dependency>
<!-- 添加junit4依赖 -->
<dependency>
<groupid>junit</groupid>
<artifactid>junit</artifactid>
<version> 4.11 </version>
<!-- 指定范围,在测试时才会加载 -->
<scope>test</scope>
</dependency>
<!-- 添加spring核心依赖 -->
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring-core</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-oxm</artifactid>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring-tx</artifactid>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring-jdbc</artifactid>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring-webmvc</artifactid>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring-context</artifactid>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring-context-support</artifactid>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring-aop</artifactid>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring-test</artifactid>
<version>${spring.version}</version>
</dependency>
<!-- 添加mybatis依赖 -->
<dependency>
<groupid>org.mybatis</groupid>
<artifactid>mybatis</artifactid>
<version>${mybatis.version}</version>
</dependency>
<!-- 添加mybatis/spring整合包依赖 -->
<dependency>
<groupid>org.mybatis</groupid>
<artifactid>mybatis-spring</artifactid>
<version> 1.2 . 2 </version>
</dependency>
<!-- 添加mysql驱动依赖 -->
<dependency>
<groupid>mysql</groupid>
<artifactid>mysql-connector-java</artifactid>
<version>${mysql-driver.version}</version>
</dependency>
<!-- 添加数据库连接池依赖 -->
<dependency>
<groupid>commons-dbcp</groupid>
<artifactid>commons-dbcp</artifactid>
<version> 1.2 . 2 </version>
</dependency>
<!-- 添加fastjson -->
<dependency>
<groupid>com.alibaba</groupid>
<artifactid>fastjson</artifactid>
<version> 1.1 . 41 </version>
</dependency>
<!-- 添加日志相关jar包 -->
<dependency>
<groupid>log4j</groupid>
<artifactid>log4j</artifactid>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupid>org.slf4j</groupid>
<artifactid>slf4j-api</artifactid>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupid>org.slf4j</groupid>
<artifactid>slf4j-log4j12</artifactid>
<version>${slf4j.version}</version>
</dependency>
<!-- log end -->
<!-- 映入json -->
<dependency>
<groupid>org.codehaus.jackson</groupid>
<artifactid>jackson-mapper-asl</artifactid>
<version> 1.9 . 13 </version>
</dependency>
<!-- https: //mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupid>com.fasterxml.jackson.core</groupid>
<artifactid>jackson-core</artifactid>
<version> 2.8 . 0 </version>
</dependency>
<!-- https: //mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupid>com.fasterxml.jackson.core</groupid>
<artifactid>jackson-databind</artifactid>
<version> 2.8 . 0 </version>
</dependency>
<dependency>
<groupid>commons-fileupload</groupid>
<artifactid>commons-fileupload</artifactid>
<version> 1.3 . 1 </version>
</dependency>
<dependency>
<groupid>commons-io</groupid>
<artifactid>commons-io</artifactid>
<version> 2.4 </version>
</dependency>
<dependency>
<groupid>commons-codec</groupid>
<artifactid>commons-codec</artifactid>
<version> 1.9 </version>
</dependency>
</dependencies>
<build>
<finalname>web-ssm</finalname>
</build>
</project>
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。