Contents
see List작성일 2016. 02. 06.
이클립스 Maven Update Project 시 자바 버전 변경 방지
Maven Update Project를 실행할 때마다 Java 버전이 1.5로 변경되는 문제를 해결하는 방법입니다.
문제 상황
Maven Update Project (Alt+F5) 실행 후 Java 컴파일러 버전이 의도치 않게 변경됩니다.
해결 방법
pom.xml에 maven-compiler-plugin 설정을 추가합니다.
pom.xml 설정
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
Java 11 이상인 경우
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>11</release>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
properties 방식 (간단한 방법)
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Spring Boot 프로젝트
<properties>
<java.version>11</java.version>
</properties>
적용 후 확인
- pom.xml 저장
- 프로젝트 우클릭 → Maven → Update Project (Alt+F5)
- 프로젝트 우클릭 → Properties → Java Compiler에서 버전 확인
추가 팁
- 이클립스 재시작이 필요할 수 있음
- .settings 폴더의 org.eclipse.jdt.core.prefs 파일에서 버전 확인 가능
- Update Project 시 "Force Update of Snapshots/Releases" 체크 권장
.classpath 파일 확인
<!-- JRE System Library 버전 확인 -->
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/
org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>tool
| No | 작성일 | Title |
|---|---|---|
| 318 | 2015. 10. 16. | [ maven ] maven update 시 java compile 버전이 변경될때 |
| 319 | 2015. 10. 16. | [ eclipse ] 이클립스에서 aspectJ 가 ruler 에 표시되지 않을때 |
| 309 | 2015. 06. 26. | [ eclipse ] 이클립스 오프라인 환경에서 xml 자동완성 설정하기 |
| 283 | 2015. 05. 24. | [ 기타 ] make cat.6 lan cable ( cat6 랜 케이블 만들기 ) |
| 270 | 2015. 04. 22. | [ eclipse ] 이클립스 단어추적 기능 끄고 키기 |
| 265 | 2015. 03. 23. | [ 이클립스 ] 단어 하이라이트 Toggle Mark Occurences 단축키 |