使用maven-compiler-plugin 生成指定版本的class

 使用maven-compiler-plugin 時,定義以下,web

<plugins>
   <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
     <source>1.6</source>
     <target>1.6</target>
     <encoding>UTF-8</encoding>
    </configuration>
   </plugin>
  </plugins>
maven

咱們原本是用1.6的,後面須要編譯一個1.5的包給其它人用,因而就把1.6改爲1.5,後執行package, 結果怎麼測試生成都不對,測試

幾翻折騰,最後仍是看日誌,發現這,暈,每次都沒有從新編譯,直接是拿着之前編譯的打包了,spa

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @日誌

[INFO] Nothing to compile - all classes are up to dateorm

因而就加個clean, 即clean packageget

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ YESsafeTokenServerSDK ---
[INFO] Changes detected - recompiling the module!it

從新編譯了,而後看生成的class,也是對應版本的io

最後再說明下sourcetarget做用編譯

<source>1.6</source>//指定源代碼的版本,若是是有一些不支持的特性,如範型,編譯時會提示你哪些類有問題。<target>1.6</target>//指定class目標版本

相關文章
相關標籤/搜索