Skip to content

Commit

Permalink
refactor: LazyConnectionDataSourceProxy 적용 (#519)
Browse files Browse the repository at this point in the history
* refactor: LazyConnectionDataSourceProxy 적용

* chore: local yml 수정

* chore(CrewDatabaseConfig): @primary 제거
  • Loading branch information
mikekks authored Jan 1, 2025
1 parent bea47ca commit 98d7657
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
Expand All @@ -38,12 +39,18 @@
public class CrewDatabaseConfig {

@Bean
@Primary
@ConfigurationProperties("spring.datasource")
public DataSource primaryDatasourceProperties() {
public DataSource physicalDatasource() {
return DataSourceBuilder.create().build();
}

@Bean
@Primary
public DataSource primaryDatasourceProperties() {
// LazyConnectionDataSourceProxy 적용
return new LazyConnectionDataSourceProxy(physicalDatasource());
}

@Bean(name = "primaryEntityManagerFactory")
@Primary
public LocalContainerEntityManagerFactoryBean primaryEntityManagerFactory() {
Expand Down
19 changes: 18 additions & 1 deletion main/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,21 @@ management:
prometheus:
metrics:
export:
enabled: true
enabled: true

custom:
paths:
eventApply: ${DEV_EVENT_APPLY_PATH}

sentry:
dsn: ${SENTRY_DSN}
environment: ${DEV_SENTRY_ENVIRONMENT}
servername: ${DEV_SENTRY_SERVERNAME}

logging:
slack:
webhook-uri: ${LOCAL_SENTRY_SLACK_WEBHOOK_URI}
config: classpath:logback-spring.xml
sentry:
repository-uri: ${LOCAL_SENTRY_REPOSITORY_URI}
environment: local

0 comments on commit 98d7657

Please sign in to comment.