win10系统下的jenkins,部署代码到阿里云服务器centos7,jenkins报错说maven插件不兼容和java路径找不到的情况可以参照这个博客。如果是找不到java路径,那么你就用最后面的

win10系统下的jenkins,部署代码到阿里云服务器centos7报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project order: Fatal error compiling: tools.jar not found: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/../lib/tools.jar -> [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/MojoExecutionException
tomcat Id list :1723
cp: cannot stat ‘/root/.jenkins/workspace/DeployOrder/order/target/order.war’: No such file or directory
mv: cannot stat ‘order.war’: No such file or directory
Tomcat started.
Finished: SUCCESS

报错全文:

Started by user admin
Running as SYSTEM
Building remotely on Aliyun_server_centos7.3 in workspace /root/.jenkins/workspace/DeployOrder
No credentials specified
 > /usr/local/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/local/bin/git config remote.origin.url git@github.com:fushaoleigithub/order.git # timeout=10
Fetching upstream changes from git@github.com:fushaoleigithub/order.git
 > /usr/local/bin/git --version # timeout=10
 > /usr/local/bin/git fetch --tags --force --progress -- git@github.com:fushaoleigithub/order.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > /usr/local/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > /usr/local/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 4cc9b0d597b98877cf2ac78a78043e915ea2df61 (refs/remotes/origin/master)
 > /usr/local/bin/git config core.sparsecheckout # timeout=10
 > /usr/local/bin/git checkout -f 4cc9b0d597b98877cf2ac78a78043e915ea2df61 # timeout=10
Commit message: "update mysql configuration"
 > /usr/local/bin/git rev-list --no-walk 4cc9b0d597b98877cf2ac78a78043e915ea2df61 # timeout=10
[DeployOrder] $ /bin/sh -xe /tmp/jenkins7553308970146550982.sh
+ BUILD_ID=DONTKILLME
+ . /etc/profile
++ '[' -x /usr/bin/id ']'
++ '[' -z 0 ']'
+++ /usr/bin/id -un
++ USER=root
++ LOGNAME=root
++ MAIL=/var/spool/mail/root
++ '[' 0 = 0 ']'
++ pathmunge /usr/sbin
++ case ":${PATH}:" in
++ pathmunge /usr/local/sbin
++ case ":${PATH}:" in
+++ /usr/bin/hostname
++ HOSTNAME=iz8vb4rhbik3h93v48ztfvz
++ HISTSIZE=1000
++ '[' '' = ignorespace ']'
++ export HISTCONTROL=ignoredups
++ HISTCONTROL=ignoredups
++ export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
++ '[' 0 -gt 199 ']'
++ umask 022
++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
++ '[' -r /etc/profile.d/256term.sh ']'
++ '[' ehxB '!=' ehxB ']'
++ . /etc/profile.d/256term.sh
+++ local256=
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ unset local256
++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
++ '[' -r /etc/profile.d/colorgrep.sh ']'
++ '[' ehxB '!=' ehxB ']'
++ . /etc/profile.d/colorgrep.sh
+++ /usr/libexec/grepconf.sh -c
+++ alias 'grep=grep --color=auto'
+++ alias 'egrep=egrep --color=auto'
+++ alias 'fgrep=fgrep --color=auto'
++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
++ '[' -r /etc/profile.d/colorls.sh ']'
++ '[' ehxB '!=' ehxB ']'
++ . /etc/profile.d/colorls.sh
+++ '[' '!' -t 0 ']'
+++ return
++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
++ '[' -r /etc/profile.d/lang.sh ']'
++ '[' ehxB '!=' ehxB ']'
++ . /etc/profile.d/lang.sh
+++ sourced=0
+++ '[' -n en_US.UTF-8 ']'
+++ saved_lang=en_US.UTF-8
+++ '[' -f /root/.i18n ']'
+++ LANG=en_US.UTF-8
+++ unset saved_lang
+++ '[' 0 = 1 ']'
+++ unset sourced
+++ unset langfile
++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
++ '[' -r /etc/profile.d/less.sh ']'
++ '[' ehxB '!=' ehxB ']'
++ . /etc/profile.d/less.sh
+++ '[' -x /usr/bin/lesspipe.sh ']'
+++ export 'LESSOPEN=||/usr/bin/lesspipe.sh %s'
+++ LESSOPEN='||/usr/bin/lesspipe.sh %s'
++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
++ '[' -r /etc/profile.d/vim.sh ']'
++ '[' ehxB '!=' ehxB ']'
++ . /etc/profile.d/vim.sh
+++ '[' -n '4.2.46(2)-release' -o -n '' -o -n '' ']'
+++ '[' -x /usr/bin/id ']'
++++ /usr/bin/id -u
+++ ID=0
+++ '[' -n 0 -a 0 -le 200 ']'
+++ return
++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
++ '[' -r /etc/profile.d/which2.sh ']'
++ '[' ehxB '!=' ehxB ']'
++ . /etc/profile.d/which2.sh
+++ alias 'which=alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
++ '[' -r /etc/profile.d/sh.local ']'
++ '[' ehxB '!=' ehxB ']'
++ . /etc/profile.d/sh.local
++ unset i
++ unset -f pathmunge
++ export MAVEN_HOME=/root/apache-maven-3.6.3
++ MAVEN_HOME=/root/apache-maven-3.6.3
++ export PATH=/root/apache-maven-3.6.3/bin:/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
++ PATH=/root/apache-maven-3.6.3/bin:/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
++ pwd
+ export PROJ_PATH=/root/.jenkins/workspace/DeployOrder
+ PROJ_PATH=/root/.jenkins/workspace/DeployOrder
+ export TOMCAT_APP_PATH=/root/apache-tomcat-9.0.34
+ TOMCAT_APP_PATH=/root/apache-tomcat-9.0.34
+ sh /root/.jenkins/workspace/DeployOrder/order/deploy.sh
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.lesson:order:war:1.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-war-plugin is missing. @ line 96, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] --------------------------< com.lesson:order >--------------------------
[INFO] Building order 1.0
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ order ---
[INFO] Deleting /root/.jenkins/workspace/DeployOrder/order/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ order ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ order ---
[INFO] Compiling 9 source files to /root/.jenkins/workspace/DeployOrder/order/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.709 s
[INFO] Finished at: 2020-04-17T12:13:16+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project order: Fatal error compiling: tools.jar not found: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/../lib/tools.jar -> [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/MojoExecutionException
tomcat Id list :1723
cp: cannot stat ‘/root/.jenkins/workspace/DeployOrder/order/target/order.war’: No such file or directory
mv: cannot stat ‘order.war’: No such file or directory
Tomcat started.
Finished: SUCCESS

原因:
由于当前项目所需jdk版本和Jenkins中使用的jdk版本不一致导致的,当前项目的pom.xml中定义了java版本为1.8,但是Jenkins中配配置的JDK版本却为1.7

 

image.png

解决办法:
修改Jenkins中系统配置-全局工具配置中jdk版本为项目所需jdk版本即可

 


这个方法是可行的!大家可以试试!!!!完全没问题

jenkins报错说maven插件不兼容和java路径找不到的情况可以参照这个博客。如果是找不到java路径,那么你就用最后面的这个方法好了,对你来说是最好的。而且如果再出先找不到java路径,大家可以看我的这个博客来重新配置一下你的jenkins对Linux系统的java路径:https://blog.csdn.net/wise18146705004/article/details/105577028

但是呢,因为你已经安装了java对不对?那你就不要这样了,我推荐你用这个(
目的在于卸载系统自带的java,然后重新安装一个自己的java,并配置一下java的环境变量,也就是重新再来一次,对你来说可能更好)
https://blog.csdn.net/hui_2016/article/details/69941850。用起来还是很好的。上面讲的很详细,你照着操作一下可以学到不少东西!!!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

人生如路兮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值