👉 기본 환경
- Language: Java
- DB: MySQL
- IDE: IntelliJ
⌨️ 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.14'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '11'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
}
tasks.named('test') {
useJUnitPlatform()
}
|
🖨️오류
1
2
3
4
|
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
|
📡 원인
DB 연결 정보가 설정되지 않음
📰 해결 방법
application.yml에 DB 정보 설정
* application.properties와 동일하나, 문법이 다름
1
2
3
4
5
6
7
|
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mydb?serverTimezone=Asia/Seoul
username: DB_생성_시_입력한_username
password: DB_생성_시_입력한_password
|
📚 참고 자료
'Java > Spring with Error' 카테고리의 다른 글
[해결 방법] org.json.JSONException (0) | 2023.08.19 |
---|---|
[해결 방법] java.lang.IllegalStateException (0) | 2023.08.19 |
[해결 방법] java: array required, but java.util.List<> found (0) | 2023.06.18 |
[해결 방법] finished with non-zero exit value 1 (0) | 2023.06.14 |
[해결 방법] Package name does not correspond to the file path (0) | 2023.06.06 |