Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
Chore : 배포 확인용 임시 핸들러 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kihyuk-jeong committed May 10, 2021
1 parent 47bfd28 commit 6133f55
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 102 deletions.
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
//package com.flab.shoeauction.common.config;
//
//import static com.flab.shoeauction.common.utils.constants.DataSourceConstants.MASTER;
//import static com.flab.shoeauction.common.utils.constants.DataSourceConstants.SLAVE;
//
//import com.flab.shoeauction.common.db.DynamicRoutingDataSource;
//import com.zaxxer.hikari.HikariDataSource;
//import java.util.HashMap;
//import java.util.Map;
//import javax.persistence.EntityManagerFactory;
//import javax.sql.DataSource;
//import lombok.RequiredArgsConstructor;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.jdbc.DataSourceBuilder;
//import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy;
//import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.DependsOn;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.env.Environment;
//import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy;
//import org.springframework.orm.jpa.JpaTransactionManager;
//import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
//import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
//import org.springframework.transaction.PlatformTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//
//@RequiredArgsConstructor
//@Configuration
//@EnableTransactionManagement
//public class RoutingDataSourceConfig {
//
// private final Environment env;
//
// @ConfigurationProperties(prefix = "spring.datasource.hikari.master")
// @Bean
// public DataSource masterDataSource() {
// return DataSourceBuilder.create().type(HikariDataSource.class).build();
// }
//
// @ConfigurationProperties(prefix = "spring.datasource.hikari.slave")
// @Bean
// public DataSource slaveDataSource() {
// return DataSourceBuilder.create().type(HikariDataSource.class).build();
// }
//
// @DependsOn({"masterDataSource", "slaveDataSource"})
// @Bean
// public DataSource routingDataSource(
// @Qualifier("masterDataSource") DataSource master,
// @Qualifier("slaveDataSource") DataSource slave) {
// DynamicRoutingDataSource routingDataSource = new DynamicRoutingDataSource();
//
// Map<Object, Object> dataSourceMap = new HashMap<>();
//
// dataSourceMap.put(MASTER, master);
// dataSourceMap.put(SLAVE, slave);
//
// routingDataSource.setTargetDataSources(dataSourceMap);
// routingDataSource.setDefaultTargetDataSource(master);
//
// return routingDataSource;
// }
//
// @DependsOn({"routingDataSource"})
// @Bean
// public DataSource dataSource(DataSource routingDataSource) {
// return new LazyConnectionDataSourceProxy(routingDataSource);
// }
//
// @Primary
// @Bean
// public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
// LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
// em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
// em.setDataSource(dataSource);
// em.setPackagesToScan("com.flab.shoeauction.domain");
//
// Map<String, Object> properties = new HashMap<>();
// properties.put("hibernate.physical_naming_strategy",
// SpringPhysicalNamingStrategy.class.getName());
// properties.put("hibernate.implicit_naming_strategy",
// SpringImplicitNamingStrategy.class.getName());
// properties.put("hibernate.hbm2ddl.auto", env.getProperty("spring.jpa.hibernate.ddl-auto"));
// em.setJpaPropertyMap(properties);
//
// return em;
// }
//
// @Primary
// @Bean
// public PlatformTransactionManager transactionManager(
// EntityManagerFactory entityManagerFactory) {
// JpaTransactionManager transactionManager = new JpaTransactionManager();
// transactionManager.setEntityManagerFactory(entityManagerFactory);
//
// return transactionManager;
// }
//}
package com.flab.shoeauction.common.config;

import static com.flab.shoeauction.common.utils.constants.DataSourceConstants.MASTER;
import static com.flab.shoeauction.common.utils.constants.DataSourceConstants.SLAVE;

import com.flab.shoeauction.common.db.DynamicRoutingDataSource;
import com.zaxxer.hikari.HikariDataSource;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy;
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@RequiredArgsConstructor
@Configuration
@EnableTransactionManagement
public class RoutingDataSourceConfig {

private final Environment env;

@ConfigurationProperties(prefix = "spring.datasource.hikari.master")
@Bean
public DataSource masterDataSource() {
return DataSourceBuilder.create().type(HikariDataSource.class).build();
}

@ConfigurationProperties(prefix = "spring.datasource.hikari.slave")
@Bean
public DataSource slaveDataSource() {
return DataSourceBuilder.create().type(HikariDataSource.class).build();
}

@DependsOn({"masterDataSource", "slaveDataSource"})
@Bean
public DataSource routingDataSource(
@Qualifier("masterDataSource") DataSource master,
@Qualifier("slaveDataSource") DataSource slave) {
DynamicRoutingDataSource routingDataSource = new DynamicRoutingDataSource();

Map<Object, Object> dataSourceMap = new HashMap<>();

dataSourceMap.put(MASTER, master);
dataSourceMap.put(SLAVE, slave);

routingDataSource.setTargetDataSources(dataSourceMap);
routingDataSource.setDefaultTargetDataSource(master);

return routingDataSource;
}

@DependsOn({"routingDataSource"})
@Bean
public DataSource dataSource(DataSource routingDataSource) {
return new LazyConnectionDataSourceProxy(routingDataSource);
}

@Primary
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setDataSource(dataSource);
em.setPackagesToScan("com.flab.shoeauction.domain");

Map<String, Object> properties = new HashMap<>();
properties.put("hibernate.physical_naming_strategy",
SpringPhysicalNamingStrategy.class.getName());
properties.put("hibernate.implicit_naming_strategy",
SpringImplicitNamingStrategy.class.getName());
properties.put("hibernate.hbm2ddl.auto", env.getProperty("spring.jpa.hibernate.ddl-auto"));
em.setJpaPropertyMap(properties);

return em;
}

@Primary
@Bean
public PlatformTransactionManager transactionManager(
EntityManagerFactory entityManagerFactory) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory);

return transactionManager;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.flab.shoeauction.controller;

import com.flab.shoeauction.common.annotation.LoginCheck;
import com.flab.shoeauction.controller.dto.AdminDto;
import com.flab.shoeauction.controller.dto.UserDto.UserBanRequest;
import com.flab.shoeauction.controller.dto.UserDto.UserDetailsResponse;
import com.flab.shoeauction.controller.dto.UserDto.UserListResponse;
Expand Down

0 comments on commit 6133f55

Please sign in to comment.