springboot整合NoSQL(springboot+vue开发实践笔记)


简介
NoSQL表示菲关系型数据库,不需要用SQL语句查询。不需要固定表格模式存储。
NoSQL数据库分以下几类
1、Key/value存储,有Redis,Tokyo Cabinet。
特点:无数据结构,二进制形式存储数据或者字符串,数据加载速度快。
使用场景:高并发,日志信息。
2、列存储系统库,有HBase、Cassandra
特点:查找速度快啊,容易进行分布式扩展。
使用:分布式文件系统
3、文档型数据库,有MongoDB、CouchDB
特点:与Key/value类似,没有预先表结构,数据格式相对灵活。
使用:web应用
4、图形数据库,有Neo4J、DEX
使用:构建关系图谱、例如社交网络,推荐系统

整合redis

在这里插入图片描述

linux安装

https://blog.csdn.net/slss01/article/details/88920845

windows安装

https://www.cnblogs.com/jylee/p/9844965.html

整合springboot

1、创建项目添加依赖
引入redis并且将默认工具lettuce排除,工具配置换成jedis

	<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-redis</artifactId>
			<exclusions>
				<exclusion>
					<groupId>io.lettuce</groupId>
					<artifactId>lettuce-core</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

2、配置redis(application.properties)


spring.redis.database=0
spring.redis.host=192.168.66.130
spring.redis.port=6379
spring.redis.password=123@456
spring.redis.lettuce.pool.max-active=
spring.redis.lettuce.pool.max-idle=
spring.redis.lettuce.pool.max-wait=
spring.redis.lettuce.pool.min-idle=
spring.redis.lettuce.shutdown-timeout=
#连接池最大连接数
spring.redis.jedis.pool.max-active=8
#连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=8
#连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1ms
#连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=0

controller.java

package org.sang;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by sang on 2018/7/18.
 */
@RestController
public class BookController {
   
    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    StringRedisTemplate stringRedisTemplate;

    @GetMapping("/test1")
    public void test1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值