store update
This commit is contained in:
parent
4946be1f49
commit
c281299d94
@ -1,5 +1,6 @@
|
|||||||
package com.ktds.hi.analytics.infra.config;
|
package com.ktds.hi.analytics.infra.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
@ -9,7 +10,15 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
|||||||
* JPA Auditing 및 Repository 스캔 설정
|
* JPA Auditing 및 Repository 스캔 설정
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableJpaAuditing
|
@EnableJpaRepositories(basePackages = {
|
||||||
@EnableJpaRepositories(basePackages = "com.ktds.hi.analytics.infra.gateway.repository")
|
// "com.ktds.hi.store.infra.gateway.entity",
|
||||||
|
"com.ktds.hi.common.repository"
|
||||||
|
})
|
||||||
|
@EntityScan(basePackages = {
|
||||||
|
"com.ktds.hi.store.infra.gateway.entity",
|
||||||
|
"com.ktds.hi.common.entity",
|
||||||
|
"com.ktds.hi.common.audit"
|
||||||
|
})
|
||||||
|
@EnableJpaAuditing(auditorAwareRef = "customAuditorAware")
|
||||||
public class JpaConfig {
|
public class JpaConfig {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import org.springframework.data.redis.cache.RedisCacheManager;
|
|||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||||
|
// import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
|||||||
"com.ktds.hi.common.entity",
|
"com.ktds.hi.common.entity",
|
||||||
"com.ktds.hi.common.audit"
|
"com.ktds.hi.common.audit"
|
||||||
})
|
})
|
||||||
@EnableJpaRepositories(basePackages = "com.ktds.hi.common.repository")
|
// @EnableJpaRepositories(basePackages = "com.ktds.hi.common.repository")
|
||||||
public class CommonModuleConfiguration {
|
public class CommonModuleConfiguration {
|
||||||
// 설정 클래스는 어노테이션만으로도 충분
|
// 설정 클래스는 어노테이션만으로도 충분
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,11 @@ package com.ktds.hi.store;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||||
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,16 +20,24 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
"com.ktds.hi.store",
|
"com.ktds.hi.store",
|
||||||
"com.ktds.hi.common"
|
"com.ktds.hi.common"
|
||||||
})
|
})
|
||||||
|
@EnableJpaRepositories(basePackages = {
|
||||||
@EnableJpaAuditing
|
"com.ktds.hi.store.infra.gateway.repository", // 👈 MenuJpaRepository 패키지
|
||||||
|
"com.ktds.hi.common.repository"
|
||||||
|
})
|
||||||
|
@EntityScan(basePackages = {
|
||||||
|
"com.ktds.hi.store.infra.gateway.entity",
|
||||||
|
"com.ktds.hi.common.entity"
|
||||||
|
})
|
||||||
|
@EnableJpaAuditing(auditorAwareRef = "customAuditorAware")
|
||||||
public class StoreApplication {
|
public class StoreApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(StoreApplication.class, args);
|
SpringApplication.run(StoreApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 👈 이 부분만 추가
|
// 기존 빈들...
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnMissingBean(RestTemplate.class) // 👈 다른 빈이 없을 때만 생성
|
||||||
public RestTemplate restTemplate() {
|
public RestTemplate restTemplate() {
|
||||||
return new RestTemplate();
|
return new RestTemplate();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,46 @@
|
|||||||
|
package com.ktds.hi.store.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RedisConfig {
|
||||||
|
|
||||||
|
@Value("${spring.data.redis.host:localhost}")
|
||||||
|
private String redisHost;
|
||||||
|
|
||||||
|
@Value("${spring.data.redis.port:6379}")
|
||||||
|
private int redisPort;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisConnectionFactory redisConnectionFactory() {
|
||||||
|
return new LettuceConnectionFactory(redisHost, redisPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
|
||||||
|
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||||
|
template.setConnectionFactory(connectionFactory);
|
||||||
|
|
||||||
|
// 직렬화 설정
|
||||||
|
template.setKeySerializer(new StringRedisSerializer());
|
||||||
|
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||||
|
template.setHashKeySerializer(new StringRedisSerializer());
|
||||||
|
template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||||
|
|
||||||
|
template.afterPropertiesSet();
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory connectionFactory) {
|
||||||
|
return new StringRedisTemplate(connectionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package com.ktds.hi.store.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RestTemplateConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public RestTemplate restTemplate() {
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 또는 더 나은 설정으로
|
||||||
|
@Bean("configuredRestTemplate")
|
||||||
|
public RestTemplate configuredRestTemplate(RestTemplateBuilder builder) {
|
||||||
|
return builder.connectTimeout(Duration.ofSeconds(5)).readTimeout(Duration.ofSeconds(10))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package com.ktds.hi.store.infra.gateway;
|
package com.ktds.hi.store.infra.gateway;
|
||||||
|
|
||||||
import com.ktds.hi.store.biz.usecase.out.CachePort;
|
import com.ktds.hi.store.biz.usecase.out.CachePort;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
@ -15,6 +16,7 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
// @NoArgsConstructor(force = true)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CacheAdapter implements CachePort {
|
public class CacheAdapter implements CachePort {
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import org.springframework.data.annotation.CreatedDate;
|
|||||||
import org.springframework.data.annotation.LastModifiedDate;
|
import org.springframework.data.annotation.LastModifiedDate;
|
||||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user