IDEA搭建项目所需准备:idea开发工具、jdk1.7、mysql、Navicat、maven
一、创建maven项目
1、 file -----> new -----> project
![c6f9d4172aaee478641496b2c1bd0a46.png](https://img-blog.csdnimg.cn/img_convert/c6f9d4172aaee478641496b2c1bd0a46.png)
![8cee1ba067a5f3aca3fce06fa997e188.png](https://img-blog.csdnimg.cn/img_convert/8cee1ba067a5f3aca3fce06fa997e188.png)
2、点击 next
![90a790dfa2cef831e6568b158c440be6.png](https://img-blog.csdnimg.cn/img_convert/90a790dfa2cef831e6568b158c440be6.png)
3、点击 next
![c1288be24e4b094ea32f206fb6624fd7.png](https://img-blog.csdnimg.cn/img_convert/c1288be24e4b094ea32f206fb6624fd7.png)
4、点击 next
![dfeb59aedd92e14d2e5024280b1c2c8f.png](https://img-blog.csdnimg.cn/img_convert/dfeb59aedd92e14d2e5024280b1c2c8f.png)
5、点击 finish ,静静的等待项目的创建,控制台出现夏天标志,则创建maven项目成功
![689799ecbc61f82940fdd7ff2ec2c79b.png](https://img-blog.csdnimg.cn/img_convert/689799ecbc61f82940fdd7ff2ec2c79b.png)
二、创建对应的文件夹
1、在main下创建java、resources文件夹并且设置为Sources Root 和Resources Root
![68dbac212622755b435be7186eed6f80.png](https://img-blog.csdnimg.cn/img_convert/68dbac212622755b435be7186eed6f80.png)
![5a3fa620e576959dbc78cbb37f3835e0.png](https://img-blog.csdnimg.cn/img_convert/5a3fa620e576959dbc78cbb37f3835e0.png)
2、在java下建常用的包,如下图所示:
![f907a9a82d14f4dc80a5764915b6f728.png](https://img-blog.csdnimg.cn/img_convert/f907a9a82d14f4dc80a5764915b6f728.png)
3、在resources 下建文件夹,如下图所示
![3fa2bf2cdb04e495f23f6f3500f2cf4d.png](https://img-blog.csdnimg.cn/img_convert/3fa2bf2cdb04e495f23f6f3500f2cf4d.png)
4、创建jsp文件存放的文件夹
![ce8ae48760d285964ab576613ebdfeb3.png](https://img-blog.csdnimg.cn/img_convert/ce8ae48760d285964ab576613ebdfeb3.png)
三、编写对应的配置文件
1、pom.xml,里面包含了所需要的jar包
![e3137b61c26baf87924102b10bcd6c45.png](https://img-blog.csdnimg.cn/img_convert/e3137b61c26baf87924102b10bcd6c45.png)
版本控制,方便修改
<?xml version="1.0" encoding="UTF-8"?>
2、编写spring-mvc.xml
![eaa7740943d0dd0b08fc89bdcf137426.png](https://img-blog.csdnimg.cn/img_convert/eaa7740943d0dd0b08fc89bdcf137426.png)
driver=com.mysql.jdbc.Driver#driver=com.mysql.cj.jdbc.Driver#mytest为我本地的数据库名url=jdbc:mysql://localhost:3306/test#url=jdbc:mysql://192.168.220.139:3306/teaching_manageusername=root#下面输入自己数据库的密码password=123456#定义初始连接数initialSize=1#定义最大连接数maxActive=20#定义最大空闲maxIdle=20#定义最小空闲minIdle=1#定义最长等待时间maxWait=60000
3、编写spring-mybatis.xml
![ead99f961388bb852f66b53503232d88.png](https://img-blog.csdnimg.cn/img_convert/ead99f961388bb852f66b53503232d88.png)
<?xml version="1.0" encoding="UTF-8"?>
4、方便管理数据库的相关配置,所有会单独的用一个文件来存放。jdbc.properties文件
![2117a60f7f608ee9bf31f2c6daac4026.png](https://img-blog.csdnimg.cn/img_convert/2117a60f7f608ee9bf31f2c6daac4026.png)
driver=com.mysql.jdbc.Driver#driver=com.mysql.cj.jdbc.Driver#mytest为我本地的数据库名url=jdbc:mysql://localhost:3306/test#url=jdbc:mysql://192.168.220.139:3306/teaching_manageusername=root#下面输入自己数据库的密码password=123456#定义初始连接数initialSize=1#定义最大连接数maxActive=20#定义最大空闲maxIdle=20#定义最小空闲minIdle=1#定义最长等待时间maxWait=60000
5、由于编写spring-mybatis.xml时,扫描mapper下的所有xml会报错,因为下面没有xml文件,所有建一个xml文件。
![5e08c134ad121d5ade0b397901feaa54.png](https://img-blog.csdnimg.cn/img_convert/5e08c134ad121d5ade0b397901feaa54.png)
在dao下新建一个接口
![ddb803917fb472e185c48970afaad295.png](https://img-blog.csdnimg.cn/img_convert/ddb803917fb472e185c48970afaad295.png)
6、编写wen.xml
![f34899d638f63d7d42df79a3a15e4f04.png](https://img-blog.csdnimg.cn/img_convert/f34899d638f63d7d42df79a3a15e4f04.png)
Archetype Created Web ApplicationencodingFilterorg.springframework.web.filter.CharacterEncodingFilterencodingUTF-8encodingFilter/*org.springframework.web.context.ContextLoaderListenercontextConfigLocationclasspath:spring/spring-mybatis.xmlspringDispatcherServletorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:spring/spring-mvc.xml1springDispatcherServlet*.do
到此为止,所有的配置文件编写完成
四、配置tomcat,启动项目
1、
![ca38f64b1461755f5af1e0c7ab972d82.png](https://img-blog.csdnimg.cn/img_convert/ca38f64b1461755f5af1e0c7ab972d82.png)
2、
![2750351801c5e5d57154134ac85a696b.png](https://img-blog.csdnimg.cn/img_convert/2750351801c5e5d57154134ac85a696b.png)
3、
![3e27f8d6b5b01cb88a26975f5a9e2592.png](https://img-blog.csdnimg.cn/img_convert/3e27f8d6b5b01cb88a26975f5a9e2592.png)
4、
![9c02418bb581f1eec8990ca7fe6183ae.png](https://img-blog.csdnimg.cn/img_convert/9c02418bb581f1eec8990ca7fe6183ae.png)
5、
![7b6e71e8c354ebde3ebcd6c05e08e3cb.png](https://img-blog.csdnimg.cn/img_convert/7b6e71e8c354ebde3ebcd6c05e08e3cb.png)
6、
![4a94cf7cd4ceb70b485c1b244b21e8d5.png](https://img-blog.csdnimg.cn/img_convert/4a94cf7cd4ceb70b485c1b244b21e8d5.png)
7、
![e71c20a24584128175a7fe14ab22d490.png](https://img-blog.csdnimg.cn/img_convert/e71c20a24584128175a7fe14ab22d490.png)
8、启动成功
![b7f943e630b6ec920a6cc160b7cabd26.png](https://img-blog.csdnimg.cn/img_convert/b7f943e630b6ec920a6cc160b7cabd26.png)
9、访问成功
![4b5f53e83b1c45e07cb0e67c72009283.png](https://img-blog.csdnimg.cn/img_convert/4b5f53e83b1c45e07cb0e67c72009283.png)
自此,ssm整合完成,下一篇开始编写案例