maven編譯報錯 -source 1.5 中不支持 lambda(或diamond) 表達式,編碼 UTF-8 的不可映射字符

在用maven編譯項目是因爲項目中用了jdk 1.8, 編譯是報錯  -source 1.5 中不支持 lambda 表達式。linux

錯誤緣由:apache

  Maven Compiler 插件默認會加 -source 1.5 及 -target 1.5 參數來編譯(估計是爲了兼容一些比較老的 Linux 服務器操做系統,它們一般只有 JDK 5),而咱們的代碼裏使用了 JDK 7/8 的語法。服務器

解決方法:maven

 1 <project>
 2   [...]
 3   <build>
 4     [...]
 5     <plugins>
 6       <plugin>
 7         <groupId>org.apache.maven.plugins</groupId>
 8         <artifactId>maven-compiler-plugin</artifactId>
 9         <version>3.2</version>
10         <configuration>
11           <source>1.8</source>
12           <target>1.8</target>
<encoding>utf8</encoding>
13 </configuration> 14 </plugin> 15 </plugins> 16 [...] 17 </build> 18 [...] 19 </project>

轉載地址:http://ju.outofmemory.cn/entry/155158ui

相關文章
相關標籤/搜索