1

私はmavenを使っていくつかのJavaクラスをコンパイルしています。クラスの 1 つに annotation( @Override) があるため、実行するmvn compileとエラーが発生します。

 annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
        @Override

 annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
        @Override

私のシステムの Java バージョンは jdk 1.6.29 ですが、このエラーを理解できません。したがって、mavenが使用しているjdkバージョンを確認して、おそらく変更する方法があります。または、他の解決策はありますか?ありがとう。

4

1 に答える 1

2

Java ソース レベル 1.5 のコンパイル用のコンパイラ フラグを設定するように Maven ビルドに指示する必要があります。これはファイル内で行われ、プラグインpom.xmlの構成が追加されます。maven-compiler-plugin

例えば:

<plugins>
[...]
     <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.2</version>
          <executions>
              <execution>
                  <id>default-compile</id>
                  <configuration>
                       <source>1.5</source>
                       <target>1.5</target>
                  </configuration>
              </execution>
              </executions>
     </plugin>
[...]
</plugins>
于 2012-01-21T02:21:09.160 に答える