에러 내용 cannot resolve symbol 패키지명

 

해결 방법

1. 사진과 같이 build and run 을 인텔리제이로 변경

 

2. 상단 메뉴바에서 File > Invalidate Caches / Restart…를 선택하고 IDE 재실행

겪은 오류는 

cannot find symbol << 이 오류다

 

 

 

수많은 구글링 결과

plugins에는 이것을 추가하고

id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10' //

 

 

dependencies에 아래의 것을 추가하고

 	// query dsl 설정 추가
    implementation 'com.querydsl:querydsl-jpa' // querydsl
    implementation 'com.querydsl:querydsl-apt' // querydsl
    // test시에도 query dsl 모델을 사용하기 위해서는 해당 옵션을 추가
    testCompileOnly 'org.projectlombok:lombok'
    testAnnotationProcessor 'org.projectlombok:lombok

 

벗어나서 test { ... } 아래  추가로 붙여준다 

//querydsl 추가 시작
def querydslDir = "$buildDir/generated/querydsl"

querydsl {
    jpa = true
    querydslSourcesDir = querydslDir
}

sourceSets {
    main.java.srcDir querydslDir
}

configurations {
    querydsl.extendsFrom compileClasspath
}

compileQuerydsl {
    options.annotationProcessorPath = configurations.querydsl
}
// lombok을 사용하면 추가해야 cannot find symbol에러가 발생하지 않음
project.afterEvaluate {
    project.tasks.compileQuerydsl.options.compilerArgs = [
            "-proc:only",
            "-processor", project.querydsl.processors() +
                    ',lombok.launch.AnnotationProcessorHider$AnnotationProcessor'
    ]
}
//querydsl 추가 끝

 

프로젝트 설정은 다음과 같다 <프로젝트 이름: guestbook>

 

 

1.

File -> Settings 들어가서

Build, Execution, Deployment -> Compiler 메뉴

Build project automatically  체크

 

 

 

2.

Ctrl+Shift+a ( mac에서는 Cmd+Shift+a) 누르면 Action쪽 검색

Registry... 선택 

compiler.automake.alllow.when.app.running 기능

 

 

인텔리 제이 프로젝트명 변경
1. File -> Project Structure -> Project -> Project Name 변경
2. settings.gradle 프로젝트 명 변경
3. src.main.java.~~프로젝트명  파일 이름 변경 
4. 새로고침 
5. edit configurations 에서 -cp 항목 설정

 

오류내용

 org.junit.platform.launcher.core.EngineDiscoveryOrchestrator lambda$logTestDescriptorExclusionReasons$7
INFO: 0 containers and 8 tests were Method or class mismatch

 

 

해결

Settings -> Build, Execution, Deployment -> Build Tools -> Gradle 에서

Build and run using Run tests using의 속성을 Intellij IDEA로 설정

--

빌드할 때 JUnit으로 테스트가 진행 되어야 하는데 Gradle로 되어서 발생

+ Recent posts