프로그래밍/자바
maven2에서 java.nio.BufferOverflowException 에러 발생시 - 소스코드 인코딩,encoding과 OS가 다를 때 처리
panpro
2009. 7. 15. 13:53
허걱. maven2에서
[INFO] Compilation failure
Failure executing javac, but could not parse the error:
An exception has occurred in the compiler (1.5.0_19). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:419)
이런 에러가 났다. 소스코드를 전부 utf-8로 바꾼 이후 발생한 문제다.
같은 코드를 javac로 바로 빌드해 봤더니
[panboy@localhost sei]$ javac CDPMain.java
CDPMain.java:14: warning: unmappable character for encoding EUC_KR
// ??닿?? 留???? ??⑦?ㅼ????? 媛???몄?ㅺ린
^
이렇게 나온다. javac는 javac로 컴파일할 때
[panboy@localhost sei]$ javac -encoding utf-8 CDPMain.java
이렇게 해주면 되지만, 나는 지금 maven2를 사용중이기 때문에 maven2에서 환경설정을 해줘야 한다.
각 프로젝트마다 pom.xml 파일을 수정해 준다.
다음과 같이 compiler plugin 부분을 수정해 주면 된다.
<plugins>
<!-- Java Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
이제 잘 된다. ㅋ