作为Maven包运行时编译失败

时间:2011-09-16 22:05:40

标签: java maven javaw

当我作为Maven Package运行时,我遇到了这个BUILD错误。但我不确定错误是什么。有人可以帮忙吗?提前谢谢。

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Conference Organizer
[INFO]    task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 36 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to C:\Users\Wallace\Desktop\co-app\co-app\target\classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
C:\Users\Wallace\Desktop\co-app\co-app\src\main\java\com\alcatel\co\service\AdminControlService.java:[38,5] error: generics are not supported in -source 1.3


[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Fri Sep 16 06:02:09 SGT 2011
[INFO] Final Memory: 14M/34M
[INFO] ------------------------------------------------------------------------

2 个答案:

答案 0 :(得分:2)

“错误:-source 1.3”不支持泛型

我猜你的代码使用泛型,并且编译器被告知要使用不支持此类的java 1.3。

编辑: 你可能必须至少使用java 1.5

 <project>
 [...]
   <build>
   [...]
   <plugins>
     <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-compiler-plugin</artifactId>
     <version>2.3.2</version>
     <configuration>
       <source>1.5</source>
       <target>1.5</target>
     </configuration>
   </plugin>
  </plugins>
  [...]
  </build>
 [...]
 </project>

答案 1 :(得分:0)

将此添加到您的Maven POM:

<build>
  [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <!-- set compliance level here -->
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  [...]
</build>
BTW,当前版本的Maven假设1.5为默认合规级别。也许您应该升级到当前的Maven版本。