Web/Spring

[Maven/Eclipse] 빌드 시 target/generated-sources 인식 못 하는 문제

정고정 2021. 11. 7. 04:39
반응형

mapstruc를 써보려고 하는데 build해서 정상적으로 MapperImpl클래스가 생성된 것까지는 확인했다. 

그런데 테스트를 돌려보니까 Impl클래스를 못 찾아내는 문제를 발견함

Impl클래스는 /target/generated-sources/annotation/${프로젝트 패키지} 아래 생성됨

 

뭐가 문젠가 찾아보다가ㅋㅋ 다른 블로그에서 보여주는 빌드 경로가 내 것과 다른 걸 발견함

그래서 maven target generated-sources 키워드 잡고 찾았더니 빌드 소스를 따로 잡아줘야 한다는 글이 나왔다

 

https://stackoverflow.com/questions/19633505/why-are-maven-generated-sources-not-getting-compiled

 

Why are Maven generated-sources not getting compiled?

I have a plugin which generates sources under the target/generated-sources/wrappers directory. It's wired into the generate-sources phase like this: mygroupid

stackoverflow.com

그래서 pom.xml 안에다가 잡아줌

sources>source태그 안에 빌드할 때 쓸 클래스 경로 러프하게 써 주면 된다.

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<configuration>
    	<sources>
        	<source>${project.build.directory}/generated-sources/annotations</source>
        </sources>
	</configuration>
</plugin>

 

그러면 인식함

 

gradle에서는 sourceSets로 잡던 걸 maven에서는 이런 식으로 명시해줘야 하나 보다

target/generated-sources 인식 못하는 거 보니까 target/generated-test-sources도 인식 못할 것 같음 따로 잡아줘야 함

아니 다른 분들 패키지 구조 보니까 이클립스에서만 빌드를 이렇게 해주나 본데 진짜 맥 빠진다

 

 

반응형