springboot整合redis,长时间不操作连接超时

我原来的依赖是这个

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

后来一直出现连接超时

解决办法,把依赖改一下

<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>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>

如果下载不下来依赖可以去下载一个maven修改conf里的setting文件在mirrors标签里添加下边配置

<mirror>
	     <id>aliyunmaven</id>
	     <mirrorOf>central</mirrorOf>
	     <name>central库</name>
	     <url>https://maven.aliyun.com/repository/central</url>
	 </mirror>

在pom文件添加下边配置

  <repositories>
        <repository>
            <id>maven-ali</id>
            <url>https://maven.aliyun.com/repository/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </snapshots>
        </repository>
    </repositories>