Maven安装:" - 1.3"中不支持注释

Jam*_*sev 14 junit annotations maven

mvn install在我的项目上运行时,我发现它由于以下错误而失败:

C:\Repositories\blah\src\test\java\com\xxx\qm\testrunner\test\ATest.java:[11,5] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
    @Test

C:\Repositories\blah\src\test\java\com\xxx\qm\common\test\BTest.java:[11,5] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
    @Test
Run Code Online (Sandbox Code Playgroud)

jUnit 4.8然而,我的Maven依赖包括但没有任何参考1.3.

什么会导致这些错误?请指教

gre*_*ker 24

您需要通过使用maven-compiler-plugin指定maven项目的源版本.将以下内容添加到pom构建元素并设置适当的java源和目标级别.

<build>
     <defaultGoal>install</defaultGoal>
     <plugins>
          <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
               </configuration>
          </plugin>
      </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

http://maven.apache.org/plugins/maven-compiler-plugin/