springboot、mybatis、thymeleaf、bootstrap整合框架
来源:互联网 发布:unity3d天空盒神庙 编辑:程序博客网 时间:2024/06/16 01:58
现在springboot、springMVC、mybatis、bootstrap用来做项目后台管理系统很常见,变自己搭建了一套来学习下,采用了jdl1.8和boot1.5.8的版本,因为目前1.8的jdk出了很多新语法,让一些代码得以简化。
首先在eclipse中创建一个maven项目
下一步后根据自己的需求编写项目名和包名完成,在根据springmav的原理把包名建好,此图为我的项目结构
在pom.xml中添加需要的maven架包,
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.inspinia</groupId>
<artifactId>INSPINIA</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
</parent>
<dependencies>
<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.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>17.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- <dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency> -->
</dependencies>
<build>
<finalName>INSPINIA</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
保存之后就是新建需要的类
1、controller
@Controller
public class UserController {
@Autowired
public UserService userService;
@RequestMapping(value="/index", method=RequestMethod.GET)
public String index(Model model){
User u = userService.findUser(1L);
model.addAttribute("user",u);
return "user/user";
}
}
2、service
@Service
public class UserService {
@Autowired
private UserDao userDao;
public User findUser(Long userId){
return userDao.findUser(userId);
}
}
3、dao
@Mapper
public interface UserDao {
public User findUser(@Param("userId")Long userId);
}
4、实体类
public class User {
private int id;
private String loginName;
}
5、xml
这里的xml建立的目录只要在配置中配置好就可以扫描到了
6、因为这里需要整合前台页面,则需要用thymeleaf和他的full-layout布局 那么这里需要几个html文件和java类,一些html的title 左边的
功能模块则需要单独提出
某个页面所需要的功能就直接单独写出来可以了
这些做完了那么就可以启动springboot的main方法
输入:http://127.0.0.1:8001/INSPINIA/index
输入框的那个1是从mysql中查询出来在前台显示的
代码:http://download.csdn.net/download/mm1164189940/10142278
- springboot、mybatis、thymeleaf、bootstrap整合框架
- JavaEE开发之SpringBoot整合MyBatis以及Thymeleaf模板引擎
- springboot整合thymeleaf模板
- SpringBoot整合thymeleaf模板
- springboot整合thymeleaf
- SpringBoot与Thymeleaf整合
- springboot thymeleaf简单整合
- springBoot整合thymeleaf
- SpringBoot-mybatis- thymeleaf
- springboot + thymeleaf + mybatis + ueditor
- 简单的SpringBoot+Mybatis框架整合
- SpringBoot整合模板引擎Thymeleaf
- springBoot thymeleaf与Spring整合
- SpringBoot + Thymeleaf 整合实例讲解
- springmvc+mybatis+Rest + html bootstrap 框架整合
- springmvc整合mybatis框架源码 bootstrap html5
- springmvc4 mybatis 整合 框架源码 bootstrap html5
- springmvc4 mybatis 整合 框架源码 bootstrap maven
- MSSQL Transact-SQL 扩展插件分批删除多条
- Bailian4104 单词翻转【堆栈+字符流】(POJ NOI0107-27)
- codeforces-892B Wrath
- Lucene之模糊、精确、匹配、范围、多条件查询-yellowcong
- java中的四种引用(强、弱、软、虚)和GC的关系
- springboot、mybatis、thymeleaf、bootstrap整合框架
- HTML-列表篇
- Firewall
- 实验测试1《C++ Primer》第五版——第十三章 拷贝控制
- linux系统下openVPN的使用
- Utunbu16.04安装后的系统整理及常用软件安装
- Lucene之分页查询的三种方式-yellowcong
- C51(AT89C52)同济大学出版社《单片机原理及应用》(魏鸿磊)第六章第12题答案
- 读书笔记《C++ Primer》第五版——第十四章 重载运算与类型转换