Skip to content

Commit

Permalink
refactor: DataSource 설정에서 show-sql 설정을 @value를 통해 주입받도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
starwook committed Sep 3, 2024
1 parent c9ee2a2 commit d539783
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion order/src/main/java/com/watermelon/server/Scheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Scheduler {

private final OrderEventSchedulingService orderEventSchedulingService;
private final CurrentOrderEventManageService currentOrderEventManageService;
@Scheduled(fixedRate = 50000)
@Scheduled(fixedRate = 500)
public void checkOrderEvent(){
Long currentEventId = currentOrderEventManageService.getCurrentOrderEventId();
orderEventSchedulingService.changeOrderStatusByTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class DatasourceConfig {
@Value("${spring.datasource1.hikari.leak-detection-threshold}")
private long leakDetectionThreshold;

@Value("${spring.jpa.show-sql}")
private boolean showSql;

@Bean
@Primary
public DataSource dataSource() {
Expand All @@ -64,7 +67,7 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory(
) {
Map<String,Object> properties = new HashMap<>();
properties.put("dialect", "org.hibernate.dialect.MySQL8InnoDBDialect");
properties.put("hibernate.show_sql", true);
properties.put("hibernate.show_sql", showSql);
properties.put("hibernate.format_sql", true);
// properties.put("hibernate.ddl-auto", "update");
properties.put("open_in_view", "false");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public class OrderResultDataSourceConfig {
@Value("${spring.datasource1.password}")
private String password;

@Value("${spring.jpa.show-sql}")
private boolean showSql;

private int maximumPoolSize =10;

@Bean(name = "orderResultDatasource")
Expand All @@ -47,7 +50,7 @@ public HikariDataSource orderResultDataSource() {
hikariConfig.setUsername(username);
hikariConfig.setPassword(password);
hikariConfig.setMaximumPoolSize(maximumPoolSize);
hikariConfig.setConnectionTimeout(250L);
hikariConfig.setConnectionTimeout(3000L);
hikariConfig.setPoolName("orderResultPool");
//orderEventQuiz만을 위한 설정 0.1초마다 확인
return new HikariDataSource(hikariConfig);
Expand All @@ -56,7 +59,7 @@ public HikariDataSource orderResultDataSource() {
public LocalContainerEntityManagerFactoryBean orderResultEntityManager(EntityManagerFactoryBuilder builder) {
Map<String,Object> properties = new HashMap<>();
properties.put("dialect", "org.hibernate.dialect.MySQL8InnoDBDialect");
properties.put("hibernate.show_sql", true);
properties.put("hibernate.show_sql", showSql);
properties.put("hibernate.format_sql", true);
// properties.put("hibernate.ddl-auto", "create");
properties.put("open_in_view", "false");
Expand Down

0 comments on commit d539783

Please sign in to comment.