「コンパイルでのJavaバージョンを指定するには」の版間の差分
提供: tknotebook
| 18行: | 18行: | ||
<version>3.5</version> | <version>3.5</version> | ||
<configuration> | <configuration> | ||
| − | |||
<source>1.8</source> | <source>1.8</source> | ||
<target>1.8</target> | <target>1.8</target> | ||
2016年10月19日 (水) 04:53時点における版
メインページ>コンピュータの部屋#Java>Maven Tips
Maven でJavaのコンパイルを行うと、Javaコンパイラのバージョンは既定で 1.5 になります。
これはもうかなり古いコンパイラなので多くの場合不適切でしょう。
maven-compiler-plugin の設定を変更するのが正攻法で、pom.xml の buildタグの中に(なければbuildタグを加え) 以下の記述を加えます。
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>