在命令行窗口查看Maven版本(mvn-v)时,出现 Error: JAVA_HOME is set to an invalid directory.的解决方法

当尝试在命令行中检查Maven版本时,遇到'JAVA_HOME isset to an invalid directory'的问题。首先怀疑是JDK版本导致,尝试更换从15到1.8,但问题依旧。进一步发现'java-version'命令无法正常运行。解决方案是删除并重新设置JAVA_HOME环境变量,问题得到解决。之后配置Path系统变量,最终成功显示Maven版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在命令行窗口查看Maven版本时,出现 Error: JAVA_HOME is set to an invalid directory.的解决方法

mvn-v

一开始认为是jdk版本问题 java15

后来换了1.8还是不行

java-version显示不出东西

1.删除JAVA_HOME后重新设置JAVA_HOME又好了

在这里插入图片描述

接下来设置Path系统变量

在这里插入图片描述

成功界面

在这里插入图片描述]

Started by user sl Running as SYSTEM Building in workspace /var/jenkins_home/workspace/sl-express-gitflow-web [WS-CLEANUP] Deleting project workspace... [WS-CLEANUP] Deferred wipeout is used... [WS-CLEANUP] Done The recommended git tool is: NONE using credential 81a93e16-3a6b-474b-8727-1293bde49842 Cloning the remote Git repository Cloning repository http://git.sl-express.com/sl/sl-express-gitflow-web.git > /usr/bin/git init /var/jenkins_home/workspace/sl-express-gitflow-web # timeout=10 Fetching upstream changes from http://git.sl-express.com/sl/sl-express-gitflow-web.git > /usr/bin/git --version # timeout=10 > git --version # 'git version 2.30.2' using GIT_ASKPASS to set credentials gogs账号 > /usr/bin/git fetch --tags --force --progress -- http://git.sl-express.com/sl/sl-express-gitflow-web.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > /usr/bin/git config remote.origin.url http://git.sl-express.com/sl/sl-express-gitflow-web.git # timeout=10 > /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 Avoid second fetch > /usr/bin/git rev-parse refs/remotes/origin/develop^{commit} # timeout=10 Checking out Revision 46c2028eb5f59801b8baca4d73fa5acbbbb33d2f (refs/remotes/origin/develop) > /usr/bin/git config core.sparsecheckout # timeout=10 > /usr/bin/git checkout -f 46c2028eb5f59801b8baca4d73fa5acbbbb33d2f # timeout=10 Commit message: "实现相乘的接口" > /usr/bin/git rev-list --no-walk 46c2028eb5f59801b8baca4d73fa5acbbbb33d2f # timeout=10 [SSH] script: chmod a+rw /var/run/docker.sock [SSH] executing... [SSH] completed [SSH] exit-status: 0 [sl-express-gitflow-web] $ /maven/bin/mvn -s /maven/conf/settings.xml -gs /maven/conf/settings.xml clean package -Dmaven.test.skip=true -U [INFO] Scanning for projects... [INFO] [INFO] -----------< com.sl-express.gitflow:sl-express-gitflow-web >------------ [INFO] Building sl-express-gitflow-web 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ sl-express-gitflow-web --- [INFO] [INFO] --- spring-boot-maven-plugin:2.6.6:build-info (default) @ sl-express-gitflow-web --- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sl-express-gitflow-web --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ sl-express-gitflow-web --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to /var/jenkins_home/workspace/sl-express-gitflow-web/target/classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ sl-express-gitflow-web --- [INFO] Not copying test resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ sl-express-gitflow-web --- [INFO] Not compiling test sources [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ sl-express-gitflow-web --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sl-express-gitflow-web --- [INFO] Building jar: /var/jenkins_home/workspace/sl-express-gitflow-web/target/sl-express-gitflow-web-1.0-SNAPSHOT.jar [INFO] [INFO] --- spring-boot-maven-plugin:2.6.6:repackage (default) @ sl-express-gitflow-web --- [INFO] Replacing main artifact with repackaged archive [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.899 s [INFO] Finished at: 2025-06-29T23:35:04+08:00 [INFO] ------------------------------------------------------------------------ [sl-express-gitflow-web] $ /bin/bash /tmp/jenkins10798732479328880887.sh chmod: cannot access 'target/-1.0-SNAPSHOT.jar': No such file or directory Docker version 20.10.17, build 100c701 ---------停止容器()--------- "docker stop" requires at least 1 argument. See 'docker stop --help'. Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...] Stop one or more running containers ---------删除容器()--------- "docker rm" requires at least 1 argument. See 'docker rm --help'. Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] Remove one or more containers ---------删除镜像(:1.0-SNAPSHOT)--------- Error response from daemon: invalid reference format ---------构建新镜像(:1.0-SNAPSHOT)--------- invalid argument ":1.0-SNAPSHOT" for "-t, --tag" flag: invalid reference format See 'docker build --help'. ---------运行服务--------- docker: invalid reference format: repository name must be lowercase. See 'docker run --help'. Build step 'Execute shell' marked build as failure Finished: FAILURE
最新发布
06-30
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/spark/spark-2.4.0-bin-hadoop2.7/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/opt/Hadoop/hadoop-2.7.2/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/opt/hbase-1.2.6/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 25/03/21 15:56:07 WARN Utils: Your hostname, master resolves to a loopback address: 127.0.0.1; using 192.168.180.130 instead (on interface ens33) 25/03/21 15:56:07 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address 25/03/21 15:56:08 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Setting default log level to "WARN". To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel). 25/03/21 15:56:09 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041. 25/03/21 15:56:12 WARN FileStreamSink: Error while looking for metadata directory. Traceback (most recent call last): File "/home/abz/PycharmProjects/untitled1/2024.10.22.test.py", line 6, in <module> df = spark.read.csv("传媒综合.csv", header=True, inferSchema=True, sep="|", encoding='utf-8') File "/opt/spark/spark-2.4.0-bin-hadoop2.7/python/pyspark/sql/readwriter.py", line 472, in csv return self._df(self._jreader.csv(self._spark._sc._jvm.PythonUtils.toSeq(path))) File "/opt/spark/spark-2.4.0-bin-hadoop2.7/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py", line 1257, in __call__ File "/opt/spark/spark-2.4.0-bin-hadoop2.7/python/pyspark/sql/utils.py", line 63, in deco return f(*a, **kw) File "/opt/spark/spark-2.4.0-bin-hadoop2.7/python/lib/py4j-0
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值