作为Maven包运行时编译失败

时间:2021-09-14 20:50:08

I got this BUILD error when I run as Maven Package. But I'm not sure what's the error. Can anyone help? Thanks in advance.

当我作为Maven包运行时,我遇到了这个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 个解决方案

#1


2  

"error: generics are not supported in -source 1.3"

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

Im guessing your code uses generics and the compiler is told to use java 1.3 which does not support such.

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

edit: you might have to use at least java 1.5

编辑:您可能必须至少使用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>

#2


0  

Add this to your Maven POM:

将其添加到您的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, current versions of Maven assume 1.5 as default compliance level. Perhaps you should upgrade to a current Maven version.

顺便说一句,当前版本的Maven假设1.5为默认合规级别。也许您应该升级到当前的Maven版本。

#1


2  

"error: generics are not supported in -source 1.3"

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

Im guessing your code uses generics and the compiler is told to use java 1.3 which does not support such.

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

edit: you might have to use at least java 1.5

编辑:您可能必须至少使用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>

#2


0  

Add this to your Maven POM:

将其添加到您的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, current versions of Maven assume 1.5 as default compliance level. Perhaps you should upgrade to a current Maven version.

顺便说一句,当前版本的Maven假设1.5为默认合规级别。也许您应该升级到当前的Maven版本。