SpringBoot2.0搭建:集成MyBatis,热部署,redis写的增删改查demo(二)

本文详细介绍了如何在SpringBoot2.0项目中集成MyBatis和Redis,包括配置pom.xml、application.properties、项目设置以及创建增删改查的demo。此外,还讨论了热部署的配置,强调了IDEA可能存在的问题,并推荐使用STS。同时,提供了页面布局和模板的指导,以及自定义错误页面的方法。
摘要由CSDN通过智能技术生成

上一篇搭建起了大体架构,这一篇写个增删改查demo,

第三篇是完善第二篇的bug:第三篇

7、测试显示table 信息 

(建table,在sql 里面添加几条数据,显示到页面)

8、增加热部署功能      

(自动刷新后台java,xml代码变动情况,无需手动重启,

不过idea对它支持不大友好,建议idea写完框架后用 sts(eclipse对spring包的集成)继续修改

spring.thymeleaf.cache 设为false
或者使用springboot的devtools

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <version>1.3.0.RELEASE</version>
</dependency>
9、增加 redis设置       
(这个著名的高性能sql不用多说了吧?自行安装配置)
10、加入前端框架:layUI ,bootstrap,jquery    
(前端页面为bootstrap-table)
11、写增删查改! crud    

(前台,写个隐藏域,获取id,如果id为空,执行添加;如果id有值,执行修改;实现两个功能用一个方法)  

12、设置报错页面            

13、美化页面,规范代码  

————————————————————

效果:


目录结构:

 

工欲善其事必先利其器,配置几个不错的功能再写demo吧:

主页:Application.java ,这里有个跳转首页的注解方法,index主页大家自己写比较好

@Controller
@SpringBootApplication
@ServletComponentScan
@EnableScheduling
@EnableCaching
@MapperScan(basePackages = {"com.example.demo.other.MyMapper"})
//启注解事务管理
@EnableTransactionManagement
public class Application {
	private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Application.class);

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
			"classpath:/META-INF/resources/", "classpath:/resources/",
			"classpath:/static/", "classpath:/public/"
	};

	@RequestMapping(value="/index",method = RequestMethod.GET)
	public String showIndex(){
		return "index";
	}

}

一、配置pom.xml,我的仅供参考 
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>demo</name>
	<description>Demo project for Spring Boot</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.3.RELEASE</version>
		<relativePath/>
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>

	</properties>

	<dependencies>

<!-- 页面模板 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>


		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.46</version>
		</dependency>

		&l
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值