From 883963dbe6a125c1113d0191a699609e20f56833 Mon Sep 17 00:00:00 2001 From: zxh_gs_lenovo Date: Wed, 4 Feb 2026 13:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E9=A1=B5=E7=9A=84?= =?UTF-8?q?=E5=8C=85=E7=89=88=E6=9C=AC=E4=BB=A5=E5=8F=8Aredis=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E9=83=A8=E7=BD=B2=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=8F=AF=E4=BB=A5=E6=94=BE?= =?UTF-8?q?=E5=A4=96=E9=9D=A2=EF=BC=8C=E4=BE=BF=E4=BA=8E=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 70 +++++++++---------- .../kexue/skills/config/RedissonConfig.java | 16 +++-- .../service/impl/CmsContentServiceImpl.java | 1 + src/main/resources/application-prod.yml | 8 +-- 4 files changed, 50 insertions(+), 45 deletions(-) diff --git a/pom.xml b/pom.xml index 70ffa0d..9e560a5 100644 --- a/pom.xml +++ b/pom.xml @@ -164,41 +164,41 @@ com.github.pagehelper pagehelper-spring-boot-starter - 1.4.2 - - - org.mybatis - mybatis - - - org.mybatis - mybatis.spring - - - log4j-slf4j-impl - org.apache.logging.log4j - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - org.slf4j - log4j-over-slf4j - - - org.slf4j - jul-to-slf4j - - - org.springframework.boot - spring-boot-starter-logging - - + 2.1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/kexue/skills/config/RedissonConfig.java b/src/main/java/com/kexue/skills/config/RedissonConfig.java index ee3fc46..347b075 100644 --- a/src/main/java/com/kexue/skills/config/RedissonConfig.java +++ b/src/main/java/com/kexue/skills/config/RedissonConfig.java @@ -16,16 +16,16 @@ import org.springframework.context.annotation.Configuration; @Configuration public class RedissonConfig { - @Value("${common.redis.host}") + @Value("${spring.redis.host}") private String host; - @Value("${common.redis.port}") + @Value("${spring.redis.port}") private int port; - @Value("${common.redis.password}") + @Value("${spring.redis.password}") private String password; - @Value("${common.redis.database}") + @Value("${spring.redis.database}") private int database; @Bean(destroyMethod = "shutdown") @@ -35,12 +35,16 @@ public class RedissonConfig { // 单节点模式 config.useSingleServer() .setAddress("redis://" + host + ":" + port) - .setPassword(password) + //.setPassword(password) .setDatabase(database) .setConnectionMinimumIdleSize(5) .setConnectionPoolSize(20) .setTimeout(10000); - + + // 处理密码:如果有密码则设置,否则不设置 + if (password != null && !password.isEmpty()) { + config.useSingleServer().setPassword(password); + } return Redisson.create(config); } diff --git a/src/main/java/com/kexue/skills/service/impl/CmsContentServiceImpl.java b/src/main/java/com/kexue/skills/service/impl/CmsContentServiceImpl.java index 071b4b6..4de633d 100644 --- a/src/main/java/com/kexue/skills/service/impl/CmsContentServiceImpl.java +++ b/src/main/java/com/kexue/skills/service/impl/CmsContentServiceImpl.java @@ -1,5 +1,6 @@ package com.kexue.skills.service.impl; +import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.kexue.skills.entity.CmsContent; diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index c9fbc98..18cc7e4 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -14,10 +14,10 @@ spring: maximum-pool-size: 30 # Redis配置,引用公共配置 redis: - host: ${common.redis.host} - port: ${common.redis.port} - password: ${common.redis.password} - database: ${common.redis.database} + host: 192.168.153.100 + port: 6379 + password: + database: 1 timeout: 10000 lettuce: pool: