1.pom依赖:
即:spring-boot的基本jar ---- 内置springmvc和spring
Thymeleaf jar
热部署 jar ---方便二次加载 ctrl+f9再次编译
Mybatis jar
Mysql jar <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency> <!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency> 2.application的配置:
#thymeleaf 配置
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
#缓存设置为false, 这样修改之后马上生效,便于调试
spring.thymeleaf.cache=false
#上下文
server.context-path=/thymeleaf
#视图层控制
#spring.mvc.view.prefix=classpath:/templates/
#spring.mvc.view.suffix=.html
#spring.mvc.static-path-pattern=/static/**
#数据库
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/how2java?characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver 3.mapper层 以及非常简单的entity层:
@Mapper
@Repository
// 加上Repository注解,即可自动bean
public interface CategoryMapper { @Select("select * from category_ ")
public List<Category> findAll(); } 4.service层 --- 以及serviceImpl实现层
@Service
public class CategoryServiceImpl implements CategoryService {
@Autowired
CategoryMapper; @Override
public List<Category> selectAll() {
return categoryMapper.findAll();
}
}
5.controller层:
这个里面加了pagehelper,可以忽略
@Controller
public class CategoryController {
@Autowired
CategoryService categoryService; @RequestMapping("/listCategory")
public String showList(Model model,
@RequestParam(value = "start", defaultValue = "0") int start,
@RequestParam(value = "size", defaultValue = "5") int size)
throws Exception{
PageHelper.startPage(start,size);
List<Category> list = categoryService.selectAll();
PageInfo<Category> page = new PageInfo<>(list);
model.addAttribute("page",page);
return "listCategory";
}
} 6.Thymeleaf --- 渲染模板: 有点类似于EL表达式的写法
<table border="1px">
<tr>
<th>id</th>
<th>name</th>
</tr>
<tr th:each="l:${page.list}">
<td th:text="${l.id}"></td>
<td th:text="${l.name}"></td>
</tr>
</table>
<a th:href="@{/listCategory(start=0)}">[首 页]</a>
<a th:href="@{/listCategory(start=${page.pageNum-1})}">[上一页]</a>
<a th:href="@{/listCategory(start=${page.pageNum+1})}">[下一页]</a>
<a th:href="@{/listCategory(start=${page.pages})}">[末 页]</a>

  

springboot --- 之SSM框架整合的更多相关文章

  1. SpringMVC详解及SSM框架整合项目

    SpringMVC ssm : mybatis + Spring + SpringMVC MVC三层架构 JavaSE:认真学习,老师带,入门快 JavaWeb:认真学习,老师带,入门快 SSM框架: ...

  2. SSM框架整合项目 :租房管理系统

    使用ssm框架整合,oracle数据库 框架: Spring SpringMVC MyBatis 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastj ...

  3. 基于maven的ssm框架整合

    基于maven的ssm框架整合 第一步:通过maven建立一个web项目.                第二步:pom文件导入jar包                              (1 ...

  4. JavaWeb之ssm框架整合,用户角色权限管理

    SSM框架整合 Spring SpringMVC MyBatis 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastjson 5, aspectwea ...

  5. SSM框架整合环境构建——基于Spring4和Mybatis3

    目录 环境 配置说明 所需jar包 配置db.properties 配置log4j.properties 配置spring.xml 配置mybatis-spring.xml 配置springmvc.x ...

  6. Springboot,SSM框架比较,区别

    百度搜 Springboot,SSM框架区别,大多说的都是 1.springboot一个应用是一个可执行jar 2.将原有的xml配置,简化为java配置 他们说的确实没错,可是根本没有说到本质,百度 ...

  7. 基于springboot的SSM框架实现返回easyui-tree所需要数据

    1.easyui-tree easui-tree目所需要的数据结构类型如下: [ { "children": [ { "children": [], " ...

  8. springmvc(二) ssm框架整合的各种配置

    ssm:springmvc.spring.mybatis这三个框架的整合,有耐心一步步走. --WH 一.SSM框架整合 1.1.整合思路 从底层整合起,也就是先整合mybatis与spring,然后 ...

  9. SSM框架整合的其它方式

    ---------------------siwuxie095                                 SSM 框架整合的其它方式         1.主要是整合 Spring ...

随机推荐

  1. Java收徒,高级架构师关门弟子

    最近感悟天命,偶有所得,故而打算收徒若干,以继吾之传承. 有缘者,可破瓶颈,走向架构师之峰,指日可待. 拜师要求: 1.工作经验:1年或以上. 2.入门费用:10000元(RMB). 联系方式(联系时 ...

  2. cocos2dx 启用cjson

    在appDelegate.cpp文件中添加 #if __cplusplus extern "C" { // 加入此代码的目的,防止污染引擎的scripting目录 #include ...

  3. EduSoho二次开发功能:单词本使用说明

    测试地址:http://shanxue.edusoho.site/ 管理账号:test 管理密码:123456 针对英语或其他语言进行单词展示,索引功能.可以针对单词进行最多三级的分类筛选,以及不限数 ...

  4. JDBC——使用JDBC连接MySQL数据库

    在JDBC--什么是JDBC一文中我们已经介绍了JDBC的基本原理. 这篇文章我们聊聊如何使用JDBC连接MySQL数据库. 一.基本操作 首先我们需要一个数据库和一张表: CREATE DATABA ...

  5. Linux下安装java环境

    准备工作: linux环境 xshell6 1.在Windows本地www,oracle.com下载对应的linux系统的JDK安装包,我下载的是 2.下载下来后,通过xftp远程传输到linux服务 ...

  6. 从零开始学习Prometheus监控报警系统

    Prometheus简介 Prometheus是一个开源的监控报警系统,它最初由SoundCloud开发. 2016年,Prometheus被纳入了由谷歌发起的Linux基金会旗下的云原生基金会( C ...

  7. 黎活明8天快速掌握android视频教程--22_访问通信录中的联系人和添加联系人

    Android系统中联系人的通讯录的contentProvide是一个单独的apk,显示在界面的contact也是一个独立的apk,联系人apk通过contentProvide访问底层的数据库. 现在 ...

  8. Git的常用命令记录

    Git的常用命令记录 1.与远程仓库建立连接,即关联一个远程库 git remote add origin git@server-name:path/repo-name.git; 2.查看当前分支  ...

  9. Spring Cloud Alibaba系列(五)sentinel实现服务限流降级

    一.sentinel是什么 sentinel的官方名称叫分布式系统的流量防卫兵.Sentinel 以流量为切入点,从流量控制.熔断降级.系统负载保护等多个维度保护服务的稳定性.在Spring Clou ...

  10. Python基础语法一

    所有内容都在代码上,有相关代码注释 # #代表注释 # 区分大小写.以回车换行结束 # 多行编写可以使用反斜杠 \ # 缩进代表一个代码块 #数值 #int类型可以使用下划线分割 c=123_456_ ...