테스트 할 때는 계속 H2를 사용해도 좋지만 애플리케이션 서버를 실행 할 때 mariaDB를 사용하자.
의존성 추가
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
</dependency>
도커로 mariaDB
docker run -p 3306:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=1 -e MYSQL_DATABASE=springjpa -e MYSQL_USER=cmlee -e MYSQL_PASSWORD=pass -d mariadb
spring.datasource.url=jdbc:mariadb://localhost:3306/springjpa
spring.datasource.username=cmlee
spring.datasource.password=pass
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.properties.hibernate.format_sql=true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
테스트 DB는 H2를 사용하고 싶다.
오버라이딩 하고 싶을 땐
application-test.properties
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.hikari.jdbc-url=jdbc:h2:mem:testdb
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
@AutoConfigureRestDocs
@Import(RestDocsConfiguration.class)
@ActiveProfiles("test")
public class EventControllerTest {