Transaction
- @Transactional을 사용하면 특정 클래스나 메서드, 인터페이스에서 commit, rollback 등을 수행(선언적 Transaction)
- Spring에서는 관련 라이브러리들을 추가, 설정해야 하지만 Boot에서는 기본 제공
- @Transaction(안에 작성한 내용에 따라 다르게 처리)
@Transaction(rollbackFor=Exception.class) | 특정 예외 발생 시 강제로 Rollback(기본) |
@Transaction(noRollbackFor=Exception.class) | 특정예외 발생 시 Rollback 처리 하지 않음. |
@Transaction(propagation=Propagation.REQUIRD) | TX 동작 도중 다른 TX 호출할 시, 어떻게 할 것인지 |
@Transaction(timeout=-1) | 지정 시간 내 수행이 완료되지 않을 경우 rollback |
@Transaction(readOnly=true) | insert, update, delete 실행 시 예외 발생 |
Isolation | |
Isolation.DEFAULT(기본) == Isolation.READ_COMMITTED | 다른 트랜잭션에서 커밋된 데이터만 읽을 수 있음 |
Isolation.READ_UNCOMMITTED | 다른 트랜잭션에서 커밋되지 않은 데이터도 읽을 수 있음 |
Isolation.REPEATABLE_READ | 조회 중인 데이터를 다른 트랜잭션에서 UPDATE 불가 |
Isolation.SERIALIZABLE | 한 트랜잭션이 commit 될 때 까지 다른 트랜잭션은 CRUD 불가 |
Connection Pool 설정
- Spring Boot 2.0 이상부터는 기본으로 Hikari pool 지원
옵션 | 설명 | 기본값 |
maximum-pool-size | Pool 에 보관 가능한 최대 connection 수 * 사용할 수 있는 connection 이 없으면 connection-timeout 까지 기다림 |
10 |
connection-timeout | Pool 에 connection 을 요청하고 기다리는 최대 시간 * 이 시간이 넘어가면 SQLException 발생 |
30000(30초) |
idle-timeout | Pool 에서 놀고 있는 connection 을 폐기하기 까지 기다리는 시간 | 600000(10분) |
max-lifetime | Connection 의 최대 유지 시간 * 시간이 지난다고 바로 폐기 하지 않고, 작업이 끝나면 바로 폐기 |
1800000(30분) |
- application.properties
- 기본값이라 설정해도 변경되는 것 없음
# connection pool
#default = 10
spring.datasource.hikari.maximum-pool-size=10
# default = 30sec = 30000ms
spring.datasource.hikari.connection-timeout=30000
# default = 10min
spring.datasource.hikari.idle-timeout=600000
# default = 30min
spring.datasource.hikari.max-lifetime=1800000
CSS 일괄적용
- src/main/resources/static 에 css 폴더 생성 >> css파일 생성 >> 적용할 style 입력
table, th, td{
border : 1px solid black;
border-collapse: collapse;
padding : 5px 10px;
}
td{
text-align: center;
}
#login{
margin-bottom: 20px;
}
button{
margin: 5px;
}
table{
width: 500px;
}
- application.properties(경로설정)
# static file
spring.mvc.static-path-pattern=/resouces/**
'코딩도전기 > Spring Boot' 카테고리의 다른 글
Spring Boot - Properties / AOP(Interceptor) (0) | 2023.06.02 |
---|---|
Spring Boot - REST API (0) | 2023.05.31 |
String Boot - Restful Service (0) | 2023.05.30 |
Spring Boot - 쿼리문 로고 찍기 / 동적쿼리 (0) | 2023.05.25 |
Spring Boot (0) | 2023.05.24 |