본문 바로가기

백엔드

Maven - cannot find symbol symbol

Maven 빌드 중 아래 오류가 발생함.

[DEBUG] incrementalBuildHelper#beforeRebuildExecution

[INFO] Compiling 47 source files to C:\dev\workspace-class\spring-mybatis-grid\target\classes

[DEBUG] incrementalBuildHelper#afterRebuildExecution

[INFO] /C:/[경로]/java/com/edu/test/NamingReflection.java: C:\dev\workspace-class\spring-mybatis-grid\src\main\java\com\edu\test\NamingReflection.java uses unchecked or unsafe operations.

[INFO] /C:/[경로]/java/com/edu/test/NamingReflection.java: Recompile with -Xlint:unchecked for details.

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR :

[INFO] -------------------------------------------------------------

[ERROR] /C:/[경로]/java/com/edu/test/DepartmentsServiceTest.java:[12,17] package org.junit does not exist

[ERROR] /C:/[경로]/java/com/edu/test/DepartmentsServiceTest.java:[13,24] package org.junit.runner does not exist

[ERROR] /C:/[경로]/java/com/edu/test/DepartmentsServiceTest.java:[14,40] package org.springframework.test.context does not exist

[ERROR] /C:/[경로]/java/com/edu/test/DepartmentsServiceTest.java:[15,47] package org.springframework.test.context.junit4 does not exist

[ERROR] /C:/[경로]/java/com/edu/test/DepartmentsServiceTest.java:[20,2] cannot find symbol symbol: class RunWith

[ERROR] /C:/[경로]/java/com/edu/test/DepartmentsServiceTest.java:[21,2] cannot find symbol symbol: class ContextConfiguration


오류나는 클래스를 살펴보니 모두 TEST 케이스에서만 에러난다.

패키지를 못 읽어 오는 것이기에 pom.xml 을 수정해야 한다.

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> <scope>test</scope> </dependency>

에서 scope 를 삭제한다. 아래처럼  

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> </dependency>