mysql jpa缓存_Springboot2.0 + jpa + redis缓存

本文基于Springboot2.0,使用mysql数据库,通过jpa实现orm,再用redis实现数据库的缓存。

目录

1、项目结构

2、环境配置

3、代码

4、测试

5、参考文章

1、项目结构

85b205f07d5b

项目结构

2、环境配置

1)pom.xml

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-test

test

mysql

mysql-connector-java

runtime

org.springframework.boot

spring-boot-starter-data-jpa

org.springframework.boot

spring-boot-starter-data-redis

2)application.yml

注意:

创建mysql数据库名称为 jpa_redis

redis 端口、

mysql 数据库账号密码

server:

port: 8081

# context-path: /

spring:

redis:

host: localhost

port: 6379

datasource:

driver-class-name: com.mysql.jdbc.Driver

url: jdbc:mysql://localhost:3306/jpa_redis

username: root

password: abc

jpa:

hibernate:

ddl-auto: update

show-sql: true

3、代码

1)SpringBootRedisApplication

注意添加 @EnableCaching

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.cache.annotation.EnableCaching;

@SpringBootApplication

@EnableCaching

public class SpringBootRedisApplication

{

public static void main(String[] args)

{

SpringApplication.run(SpringBootRedisApplication.class, args);

}

}

2)RedisConfig

import org.springframework.cache.CacheManager;

import org.springframework.cache.annotation.CachingConfigurerSupport;

import org.springframework.cache.annotation.EnableCaching;

import org.springframework.cache.interceptor.KeyGenerator;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.data.redis.cache.RedisCacheConfiguration;

import org.springframework.data.redis.cache.RedisCac

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
springboot vue redis mysql毕业设计的例子可以是一个在线书店系统。 该系统的功能包括用户注册与登录、图书的浏览与搜索、添加购物车、在线支付、订单管理等。 首先,使用Spring Boot作为后端框架,提供RESTful API接口,处理用户注册与登录的功能。通过Spring Security实现用户认证和授权,保证系统的安全性。 然后,使用Vue作为前端框架,通过Ajax请求与后端进行数据交互。通过Vue Router实现页面之间的跳转,并使用Vuex进行状态管理,方便组件之间的数据共享。 在后端,使用Redis作为缓存数据库,提高数据读取的速度。将热门书籍、推荐书籍等频繁访问的数据存储在Redis中,减轻MySQL的压力。 同时,使用MySQL作为主要的数据库,存储用户信息、图书信息和订单信息等。通过JPA实现与数据库的连接和操作,提供数据的持久化。 对于图书的浏览与搜索功能,可以通过Vue的组件化开发,实现书籍的展示和搜索框的操作。根据用户输入的关键字,通过Ajax请求后端的API接口,从数据库中查询匹配的书籍,并展示在页面上。 购物车功能可以使用Redis存储用户的购物车信息,如图书的ID和数量。用户可以将感兴趣的书籍加入购物车,然后进行结算操作。 在订单管理方面,用户下单后,系统将订单信息存储在MySQL中,并返回给用户确认。用户可以查询自己的订单,并根据订单状态进行相应的操作,如取消订单、确认收货等。 总的来说,该毕业设计通过使用Spring Boot、Vue、RedisMySQL等技术,实现了一个具备完整功能的在线书店系统。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值