• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    해결됨

[JPA와 DB 설정, 동작확인] import Assert 오류

22.07.25 05:07 작성 조회수 459

3

[질문 템플릿]
1. 강의 내용과 관련된 질문인가요? (예/아니오)
2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (/아니오)
3. 질문 잘하기 메뉴얼을 읽어보셨나요? (/아니오)

[질문 내용]
여기에 질문 내용을 남겨주세요.
 
 
안녕하세요,
 
현재 <JPA와 DB 설정, 동작확인> 내용을 (09:13) 따라가면서 듣고 있는데 import하는 Assert 부분에서 오류가 납니다.
 
<강의>
<내 코드>
 
구글링해서 찾아보니까 (https://aonee.tistory.com/2) build.gradle에 밑 내용 넣으면 된다고 하는데 다른 방법이 있나요? 강의에서는 안 넣어도 잘 되는 것 같아서 여쭤봅니다.
 
또 제가 devtools 동작오류가 있어서 (https://www.inflearn.com/course/스프링부트-JPA-활용-1/unit/24277?tab=community&q=152186) 질문에서 알려준 사이트 내용대로 build.gradle에 apply plugin: 'idea'를 적었습니다. 저는 이 부분을 바꾸지 않는 선에서 오류를 해결하고 싶어서 다른 방법을 찾고 싶습니다.
 
 
 
추가)
비슷한 질문 보니까 build.gradle를 올리면 좋다고 하셔서 추가합니다.
https://www.inflearn.com/course/스프링부트-JPA-활용-1/unit/24279?tab=community&q=580709
 
<bulid.gradle>
plugins {
id 'org.springframework.boot' version '2.7.2'
id 'io.spring.dependency-management' version '1.0.12.RELEASE'
id 'java'
}
apply plugin: 'idea'

group = 'jpabook'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-devtools'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

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

답변 2

·

답변을 작성해보세요.

6

OMG님의 프로필

OMG

2022.07.25

안녕하세요. blackbird7님, 공식 서포터즈 OMG입니다.

Assert import 가 안되는 부분은 아래 build.gradle로 바꿔주세요

 

plugins {
id 'org.springframework.boot' version '2.7.2'
id 'io.spring.dependency-management' version '1.0.12.RELEASE'
id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//JUnit4 추가
testImplementation("org.junit.vintage:junit-vintage-engine") {
exclude group: "org.hamcrest", module: "hamcrest-core"
}
}

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

devtools가 안된다고 하셨는데 오류 내용을 올려주세요.


감사합니다.

blackbird7님의 프로필

blackbird7

질문자

2022.07.26

감사합니다! 빨간줄이 사라졌어요.

devtools같은 경우에는 오류라기보다는 (코드에 빨간줄 뜨는게 아니라) Build > Recompile 'hello.html' 한 다음 새로고침 눌렀을 때 수정한 것이 반영이 안 됐어요. 

'안녕하세요' -> '안녕' 이게 IntelliJ에서 서버 안 끄고는 변경이 안 되서 찾아보니 어떤 분이 질문에 이런 방법이 있다고 올려주신게 있더라고요. 그래서 알려준 내용대로 apply plugin: 'idea' 하고 다른 세팅하니 되더라고요.

https://www.inflearn.com/course/스프링부트-JPA-활용-1/unit/24277?tab=community&q=152186

1

Junsik Oh님의 프로필

Junsik Oh

2022.08.31

감사합니다! 위에 올려주신 junit4관련 추가하니까 에러가 사라졌습니다.