idea,navicate,tomcat
技术支持Maven,SSM(spring,springMVC,Mybatis),bootstrap前端框架,Mysql数据库
mysql设置 使用navicat建立数据库并创建一个数据表,表结构如下:
引入项目依赖的jar包
maven资源过滤配置
因为所有的bootstrap框架都依赖于jQuery,所以引入bootstrap之前都必须引入jQuery 官网下载bootstrap和jQuery
bootstrap:https://www.bootcss.com/
jQuery:https://jquery.com/idea中webapp目录下新建一个static静态目录,新建js和bootstrap目录,分别引入jQuery和bootstrap,目录结构如下
创建一个jsp文件,引入jQuery和bootstrap,结果如图
配置文件的编写
在resource目录下建立applicationContext.xml和mybatis-config.xml配置文件
基本配置如下:
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
jdbc.driver=com.mysql.jdbc.Driver#mysql 8.0 以上 添加时区配置 &serverTimezone=Asia/Shanghaijdbc.url=jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai jdbc.username=rootjdbc.password=root
idea关联数据库编写mybatis核心配置文件
4、编写实体类
pojo目录下创建一个Books实体类
public class Books { private int bookID; private String bookName; private String bookCounts; private String detail; public Books() { } public Books(int bookID, String bookName, String bookCounts, String detail) { this.bookID = bookID; this.bookName = bookName; this.bookCounts = bookCounts; this.detail = detail; } public int getBookID() { return bookID; } public void setBookID(int bookID) { this.bookID = bookID; } public String getBookName() { return bookName; } public void setBookName(String bookName) { this.bookName = bookName; } public String getBookCounts() { return bookCounts; } public void setBookCounts(String bookCounts) { this.bookCounts = bookCounts; } public String getDetail() { return detail; } public void setDetail(String detail) { this.detail = detail; } @Override public String toString() { return "Books{" + "bookID=" + bookID + ", bookName='" + bookName + ''' + ", bookCounts='" + bookCounts + ''' + ", detail='" + detail + ''' + '}'; }}
编写Mapper文件夹BookMapper:
public interface BookMapper { //插入书本 int addBook(Books books); //删除书本 int delbookByID( @Param("bookID") int id); //更新书本 int updateBook(Books books); //查询书本 Books queryBookByID( @Param("bookID") int id); //查询全部书本 List
BookMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
BookService:
public interface BookService { //插入书本 int addBook(Books books); //删除书本 int delbookByID( int id); //更新书本 int updateBook(Books books); //查询书本 Books queryBookByID( int id); //查询全部书本 List
BookServiceImpl
public class BookServiceImpl implements BookService{ //service层调用mapper层 private BookMapper bookMapper; public void setBookMapper(BookMapper bookMapper) { this.bookMapper = bookMapper; } @Override public int addBook(Books books) { return bookMapper.addBook(books); } @Override public int delbookByID(int id) { return bookMapper.delbookByID(id); } @Override public int updateBook(Books books) { return bookMapper.updateBook(books); } @Override public Books queryBookByID(int id) { return bookMapper.queryBookByID(id); } @Override public List
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
至此,idea中关于SSM的配置已经全部完成,接下来是业务处理控制以及前台代码的编写