h2 연동 에러들

 

에러문구 

Caused by: java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl,

 

 

해결

application.yml 또는 .properties 에 분명 오타 또는 띄어쓰기 잘못된거 있으니까 잘 보면 된다..

 

 

정말 삽질을 오래했는데 알고봤더니 jdbc 에서 j가 빠져있었다.. 

spring:
  datasource:
    url: jdbc:h2:tcp://localhost/~/vintage-camera-shop

 

 

 

 

에러문구 : h2 DB가 제대로 연결이 안됐다?

java.lang.ClassNotFoundException: org.h2.Driver

 

 

해결

 build.gradle 에 runtimeOnly 'com.h2database:h2'  추가하면 된다!

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-web'

    compileOnly 'org.projectlombok:lombok'

    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    runtimeOnly('org.springframework.boot:spring-boot-devtools')
    
     runtimeOnly 'com.h2database:h2'
}
반응형
LIST

+ Recent posts