Cute Blinking Unicorn

백엔드/스프링부트

인텔리 마리아디비 연동시(MariaDB 연동)

민밥통 2024. 1. 9. 14:16

https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client/3.3.2

Maven 버전 복사해와서 (MariaDB를 위한 JDBC 드라이버 설치)

plugins {
    id 'java'
    id 'war'
    id 'org.springframework.boot' version '3.2.1'
    id 'io.spring.dependency-management' version '1.1.4'
}

group = 'org.zerock'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

configurations {
    compileOnly {
       extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
    annotationProcessor 'org.projectlombok:lombok'
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    // https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client
    implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '3.3.2'

}

tasks.named('test') {
    useJUnitPlatform()
}

 

build.gradle에 넣어놓는다

 

그리고 

properties에서는 DB정보를 넣는다. 

spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://localhost:3307/bootex
spring.datasource.username=bootuser
spring.datasource.password=1234

이렇게 넣으면 완료! 데이터베이스 연동 완료! 처음에는 에러뜨는 이유가 

URL 뭐라뭐라 적혀있을 건데 어느 DB정보인지 알 수 없어서 에러가 뜬거다!