반응형
Spring Boot Connection Pool 설정
Spring boot 기본 connection pool이 spring boot 2.0.0버전부터 hikariCP로 변경되었고
Spring boot 2.0.0 이상버전에서 hikariCP를 TomcatJDBC Connection Pool 로 변경하는 방법
성능상으로 hikariCP가 다른 DBCP보다 성능은 좋지만 혹시 변경할 일이 있을 경우를 대비해 포스팅
Spring boot 초기세팅(hikaraCP)
Pom.xml
1
2
3
4
5
6
7
8
9
10
|
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
|
cs |
applicatoin.properties
1
2
3
4
5
6
7
8
9
10
11
12
|
#mysql
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/dev?useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=usrname
spring.datasource.password=pwd
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.hibernate.ddl-auto=none
logging.level.com=DEBUG
|
cs |
실행시 로그레벨을 dubug로하여 확인해보면 default 인 hakiraCP로 연결이 된다.
1. Pom.xml dependency 변경
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>10.0.16</version>
</dependency>
|
cs |
2.application.properties tomcat connection 설정 추가
1
2
3
4
5
6
7
|
#tomcat connection pool setting
spring.datasource.tomcat.initial-size=15
spring.datasource.tomcat.max-wait=20000
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-idle=15
spring.datasource.tomcat.min-idle=8
spring.datasource.tomcat.default-auto-commit=true
|
cs |
반응형
'Spring' 카테고리의 다른 글
Srping Boot Quartz DB Cluster,Log 구현 (0) | 2023.01.18 |
---|---|
Spring Boot zip END header not found (0) | 2022.11.02 |
Spring boot + JPA (1) (0) | 2022.09.26 |
Spring Data Redis 로 Redis 연동 (0) | 2022.09.20 |
Intellij Spring boot Jmx RMI remote objects have benn exported (0) | 2022.09.13 |
댓글