当前位置: 首页 > 知识库问答 >
问题:

Jenkins生成错误,消息为无法执行目标组织。阿帕奇。专家插件:maven编译器插件:3.1:在项目上编译(默认编译)

魏学智
2023-03-14

无法执行目标org.apache.maven.plugins: maven-compiler-plugin: 3.1:编译(默认编译)在Jenkins构建中的项目与错误消息

[INFO]——maven编译器插件:3.1:compile(默认编译)@projectname----
[INFO]检测到更改-重新编译模块
[INFO]将21个源文件编译为C:\Program files(x86)\Jenkins\workspace\projectname\target\classes
[INFO]----------------------------------------------------------------
[ERROR]编译错误:
[INFO]----------------------------------------------------------------
[ERROR]源选项5不再受支持。使用7或更高版本
[错误]不再支持目标选项5。使用7或更高版本
[INFO]2个错误
[INFO]-------------------------------------------------------------
[INFO]-------------------------------------------------------------
[INFO]构建失败
[INFO]-------------------------------------------------------------
[INFO]总时间:13.958秒
[INFO]完成时间:2020-07-30T14:53:55 05:45
[INFO]------------------------------------------------------------------------
等待Jenkins完成数据收集
[错误]无法执行目标组织。阿帕奇。专家plugins:maven compiler plugin:3.1:project上的compile(默认编译):编译失败:编译失败:
[ERROR]源选项5不再受支持。使用7或更高版本
[错误]不再支持目标选项5。使用7或更高版本
[错误]-

POM详情

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  
  <groupId>projectnameworkgroup</groupId>
  <artifactId>projectnameframework</artifactId>
  <version>0.0.1-SNAPSHOT</version>
   <name>projecnameautomation</name>
  <url>http://maven.apache.org</url>
 <properties>
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 </properties>
 
  
  <build>
 <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M4</version>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>MYtestNG.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
</plugins>
  </build>


  <dependencies>
     
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.14.3</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.sikuli/sikuli-api -->
<dependency>
    <groupId>org.sikuli</groupId>
    <artifactId>sikuli-api</artifactId>
    <version>1.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.assertthat/selenium-shutterbug -->
<dependency>
    <groupId>com.assertthat</groupId>
    <artifactId>selenium-shutterbug</artifactId>
    <version>0.9.3</version>
</dependency>

<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.38</version>
</dependency>

   
   <!-- https://mvnrepository.com/artifact/com.opencsv/opencsv -->
<dependency>
    <groupId>com.opencsv</groupId>
    <artifactId>opencsv</artifactId>
    <version>4.0</version>
</dependency>


<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin -->
<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.5</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/ -->
<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
</dependency>

     </dependencies>
     
 <repositories>
    <repository>
      <id>mvntestngrepo.read</id>
      <url>https://github.com/abc/projectname</url>
    </repository>
 </repositories>
 
</project>

寻找解决方案。请给出你有价值的解决方案。谢谢你

使用版本详细信息

共有1个答案

王棋
2023-03-14

看起来maven编译器插件有默认的5个目标选项
必须为该选项设置显式值<类似这样的:

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.1</version>
  <configuration>
  <encoding>UTF-8</encoding>
  <source>1.7</source>
  <target>1.7</target>
  </configuration>
</plugin>
 类似资料: