zoukankan      html  css  js  c++  java
  • SpringBoot实现Session共享

    一、创建项目并导入依赖

       

    <dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-data-redis-reactive</artifactId>

    </dependency>

    <dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-security</artifactId>

    </dependency>

    <dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-web</artifactId>

    </dependency>

    <dependency>

    <groupId>org.springframework.session</groupId>

    <artifactId>spring-session-data-redis</artifactId>

    </dependency>

       

    二、相关配置和代码

       

    Application.properies

       

    spring.redis.database=0

    spring.redis.password=fernfei

    spring.redis.host=192.168.21.130

    spring.redis.port=6379

       

       

    server.port=8080

       

       

    Controller

       

       

    三、打包测试

       

    双击打包,注意打包时把test跳过,点那个闪电就可以跳过测试

       

    在cmd中运行第一个项目

       

       

    使用新版redis必须导入security,security访问项目时需要登陆,用户名user密码

    控制台复制

       

    再在cmd运行第二个项目

       

       

       

    效果图

       

       

  • 相关阅读:
    正则表达式
    数据结构与算法-串
    数据结构与算法-优先级队列
    数据结构与算法-词典
    数据结构与算法-高级搜索树
    数据结构与算法-二叉搜索树
    数据结构与算法-图
    数据结构与算法-二叉树
    数据结构与算法-栈与队列
    数据结构与算法-列表
  • 原文地址:https://www.cnblogs.com/fernfei/p/12128013.html
Copyright © 2011-2022 走看看