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정보인지 알 수 없어서 에러가 뜬거다!
'백엔드 > 스프링부트' 카테고리의 다른 글
엔티티 클래스와 JpaRepository (0) | 2024.01.09 |
---|---|
Spring Data JPA의 소개 (0) | 2024.01.09 |
스프링부트로 이용한 쇼핑몰 만들기 (1) | 2023.12.29 |
MyBatis 스프링부트 출력 (1) | 2023.12.29 |
gpt를 통한 interface와 @Autowired와 @RequestMapping 알아가기 (0) | 2023.12.28 |