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