您现在的位置是:主页 > news > 网站备案网站建设方案/奉化云优化seo

网站备案网站建设方案/奉化云优化seo

admin2025/6/27 17:21:40news

简介网站备案网站建设方案,奉化云优化seo,光明乳业网站是谁做的,裂变分销系统文章目录报错详情分析解决方法1.尝试2.解决报错详情 在使用GitHub的配套服务Travis-CI构建java项目,出现了问题;主要是含有lambda表达式的java8通不过,之前虽然jdk也是按照jdk8进行配置,但是这次在程序中使用了java8的新特性lamb…

网站备案网站建设方案,奉化云优化seo,光明乳业网站是谁做的,裂变分销系统文章目录报错详情分析解决方法1.尝试2.解决报错详情 在使用GitHub的配套服务Travis-CI构建java项目,出现了问题;主要是含有lambda表达式的java8通不过,之前虽然jdk也是按照jdk8进行配置,但是这次在程序中使用了java8的新特性lamb…

文章目录

    • 报错详情
    • 分析
    • 解决方法
      • 1.尝试
      • 2.解决


报错详情

在使用GitHub的配套服务Travis-CI构建java项目,出现了问题;主要是含有lambda表达式的java8通不过,之前虽然jdk也是按照jdk8进行配置,但是这次在程序中使用了java8的新特性lambda表达式,所以导致构建失败了。网上找了好久,好像没有找到类似的文章,于是只能硬着头皮去看报错了。

以下是我的.travis.yml:

language: java
sudo: false
jdk:- openjdk8# codecov
script: "mvn cobertura:cobertura"after_success:- bash <(curl -s https://codecov.io/bash)

主要错误如下:(具体可见:https://travis-ci.org/yansheng836/GLPL/builds/596478583)

# 错误1
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project GLPL: Compilation failure
[ERROR] /home/travis/build/yansheng836/GLPL/src/main/java/xyz/yansheng/util/SpiderUtil.java:[118,51] lambda expressions are not supported in -source 1.5
[ERROR]   (use -source 8 or higher to enable lambda expressions)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
The command "eval mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed. Retrying, 2 of 3# 错误2
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T18:41:47Z)
Maven home: /usr/local/maven-3.6.0
Java version: 1.8.0_222, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-1037-gcp", arch: "amd64", family: "unix"
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< xyz.yansheng:GLPL >--------------------------
[INFO] Building GLPL 0.0.3-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ GLPL ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/travis/build/yansheng836/GLPL/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ GLPL ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /home/travis/build/yansheng836/GLPL/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/travis/build/yansheng836/GLPL/src/main/java/xyz/yansheng/util/SpiderUtil.java:[118,51] lambda expressions are not supported in -source 1.5(use -source 8 or higher to enable lambda expressions)
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.646 s
[INFO] Finished at: 2019-10-11T07:05:21Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project GLPL: Compilation failure
[ERROR] /home/travis/build/yansheng836/GLPL/src/main/java/xyz/yansheng/util/SpiderUtil.java:[118,51] lambda expressions are not supported in -source 1.5
[ERROR]   (use -source 8 or higher to enable lambda expressions)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
The command "eval mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed. Retrying, 3 of 3.# 最后面的错误汇总
The command "eval mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed 3 times.
The command "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V" failed and exited with 1 during .

分析

按照提示访问了 :http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException,但是没有找到相关内容。

查看错误语句Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project GLPL: Compilation failure,感觉是这个插件的版本有问题,好像只能处理1.5版本,提示版本低了,不能处理lambda expressions

于是与中央仓库查了下:https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin,发现3.1版本好像是2013年4月发布的,而jdk1.8是在2014年3月19日发布的,所以该版本不能处理java8的lambda expressions
在这里插入图片描述
既然找到问题所在,那么离解决就跟进一步了。

解决方法

1.尝试

因为之前对 Travis-CI 了解得也不是很多,所以就算是我找到的问题的缘由,还是不太懂该怎么修改才能构建成功。

后面琢磨了一番,在pom.xml中添加了最新的依赖,而不是使用默认的设置:

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

不过不知道是不是因为没有用或者是其他原因(Travis-CI是外网,可能有提交时没有实时构建),反正就是没有成功。

提示:GitHub开启Travis-CI服务后,它检测到有新的提交会自动构建。但是可能会有延迟,建议查看下提交的hash1是否是最新的,如果不是,先刷新,然后手动构建(如下图所示):
在这里插入图片描述

2.解决

后来看到这篇文章:maven如何指定项目的jdk版本(使用maven-compiler-plugin),感觉这是个方向,于是进行尝试:将该包作为构建插件,而不是依赖包

<project>
……<build><plugins>……<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>1.8</source><target>1.8</target></configuration></plugin></plugins></build>
</project>

提交、构建成功!