1. 程式人生 > >springboot專案session共享(redis)

springboot專案session共享(redis)

1.  啟動類加上註解: 

    @EnableRedisHttpSession

2.  pom檔案

        <dependency>  <-- 用於支援@EnableRedisHttpSession註解 -->
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-data-redis</artifactId>
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>



3.  application.properties配置redis連線


完成!

pom檔案中的redis

                <dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
    <version>2.9.0</version>

    <type>jar</type>
    <scope>compile</scope>

</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-pool2</artifactId>
    <version>2.4.2</version>

</dependency>

<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang --> <dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.4</version>

</dependency>

            <dependency>
                <groupId>org.springframework.session</groupId>
                <artifactId>spring-session-data-redis</artifactId>
                <version>RELEASE</version>
                <scope>compile</scope>
            </dependency>