From 74b2f0b1e9165247cbce27ef05d61ccf2868f51f Mon Sep 17 00:00:00 2001 From: sdw504512 Date: Sat, 16 Mar 2024 23:23:17 +0900 Subject: [PATCH] =?UTF-8?q?Bug:=20redis=20=EC=97=B0=EA=B2=B0=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++-- .../com/senity/waved/base/redis/RedisProperties.java | 6 +++--- .../base/security/OAuth2MemberSuccessHandler.java | 6 ++++-- src/main/resources/log4jdbc.log4j2.properties | 2 ++ src/main/resources/logback-spring.xml | 10 ++++++++++ 5 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/log4jdbc.log4j2.properties create mode 100644 src/main/resources/logback-spring.xml diff --git a/build.gradle b/build.gradle index d88c1ac..8d778f1 100644 --- a/build.gradle +++ b/build.gradle @@ -32,14 +32,14 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' - implementation 'ch.qos.logback:logback-classic:1.2.3' - implementation 'org.springframework.boot:spring-boot-starter-validation:3.1.5' implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5' runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.5' runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.5' + implementation 'org.slf4j:slf4j-logback:2.0.0' + testImplementation 'org.mockito:mockito-core:5.2.0' implementation 'org.springframework.boot:spring-boot-starter-data-redis' diff --git a/src/main/java/com/senity/waved/base/redis/RedisProperties.java b/src/main/java/com/senity/waved/base/redis/RedisProperties.java index c28238f..f7b9564 100644 --- a/src/main/java/com/senity/waved/base/redis/RedisProperties.java +++ b/src/main/java/com/senity/waved/base/redis/RedisProperties.java @@ -7,10 +7,10 @@ @Component @Getter -@PropertySource("application.yml") +@PropertySource("application-secret.yml") public class RedisProperties { - @Value("${spring.data.redis.port}") + @Value("${custom.redis.port}") private int port; - @Value("${spring.data.redis.host}") + @Value("${custom.redis.host}") private String host; } \ No newline at end of file diff --git a/src/main/java/com/senity/waved/base/security/OAuth2MemberSuccessHandler.java b/src/main/java/com/senity/waved/base/security/OAuth2MemberSuccessHandler.java index c7c18f1..14f4028 100644 --- a/src/main/java/com/senity/waved/base/security/OAuth2MemberSuccessHandler.java +++ b/src/main/java/com/senity/waved/base/security/OAuth2MemberSuccessHandler.java @@ -2,6 +2,7 @@ import com.senity.waved.base.jwt.TokenDto; import com.senity.waved.base.jwt.TokenProvider; +import com.senity.waved.base.redis.Redis; import com.senity.waved.base.redis.RedisUtil; import com.senity.waved.domain.member.entity.Member; import com.senity.waved.domain.member.repository.MemberRepository; @@ -18,6 +19,7 @@ import org.springframework.web.util.UriComponentsBuilder; import java.io.IOException; +import java.util.Optional; @Slf4j @Component @@ -40,11 +42,11 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo TokenDto token = new TokenDto(tokenProvider.createAccessToken(userEmail), tokenProvider.createRefreshToken(userEmail), member.getHasInfo()); -/* Optional optionalRedis = redisUtil.findByEmail(userEmail); + Optional optionalRedis = redisUtil.findByEmail(userEmail); if (optionalRedis.isPresent()) { redisUtil.deleteByEmail(userEmail); } - redisUtil.save(userEmail, token.getRefreshToken());*/ + redisUtil.save(userEmail, token.getRefreshToken()); String url = makeRedirectUrl(token.getAccessToken(), token.getRefreshToken(), token.getHasInfo()); response.sendRedirect(url); diff --git a/src/main/resources/log4jdbc.log4j2.properties b/src/main/resources/log4jdbc.log4j2.properties new file mode 100644 index 0000000..5f90dcf --- /dev/null +++ b/src/main/resources/log4jdbc.log4j2.properties @@ -0,0 +1,2 @@ +log4jdbc.auto.load.popular.drivers=false +log4jdbc.drivers=com.mysql.cj.jdbc.Driver \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..05bbf5f --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,10 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + +