项目搭建
1.1使用maven选择自己需要的项目:
1.2 导入依赖和修改版本号
- 右下角:
- 在pom.xml中修改版本号
- 添加依赖(我这里不全,请面向百度)
1.3 创建ssm基本的文件目录
- 目录图示
1.java文件夹——放置项目具体代码
2.resources文件夹——放置资源配置文件
3.mapper文件夹——放置Mybatis的映射文件
4.spring文件夹——放置spring、springMVC配置文件
5.db.properties——数据库配置文件
6.log4j.properties——日志配置文件
7.mybatis-config.xml——Mybatis配置文件
8.jsp文件夹——放置前端具体页面
9.target文件夹——放置项目war包 - java文件为源码,需要将文件属性设为SourceRoot
- 同理resource文件需要变成Resource Root
1.4 resource中xml配置文件设置(spring+mybaties)
- 请参考配置文件xml的代码
- 上面文章没有的:spring-mvc
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- 1将SpringMVC加载进配置文件-->
<!-- 开启SpringMVC注解模式:(1)自动注册(2)可以提供一些数据的格式化-->
<mvc:annotation-driven/>
<!--2,。加载静态资源 -->
<mvc:default