Maven parent.relativePath带给我的坑

前言

东西很简单,只是作为一个记录给后面的兄弟。周末搞了Linux上使用Maven打包遇到的问题。如果忽略排查思路可直接看解决

问题

The goal you specified requires a project to execute but there is no POM in this directory (/data/my). Please verify you invoked Maven from the correct directory

这个错误指的是当前目录没有pom文件,必须要到你项目里面,有pom文件的位置下去执行Maven命令才行。比如:mvn clean -X

这里的-X是Dubbo调试具体的错误,也可以使用-e

spring-boot-starter-parent-2.2.2.RELEASE.pom and ‘parent.relativePath’ points at wrong local POM @ line 30, column 13

之后就提示:ModelParseException异常,然后提供[Help 1]

https://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException 这个网址,进去里面一看,说的是Parent父类依赖有问题。

但是,笔者的父模块的parent依赖是spring boot

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
</parent>

这里后面Spring考虑到了说,如果当前项目需要依赖的其他的项目,并且是以上层方式导入的,可以替换为

<dependencies>
            <!-- SpringBoot的依赖配置 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.2.2.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
</dependencies>

这个与上面的parent是一样的效果。具体网址

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#getting-started.first-application.pom

题外话了,这个是创建pom文件规范的问题。

因为这个pom文件,里面使用了parent注入spring的jar包,所以呢,就导致了parent.relativePath???笔者很疑惑,为什么呢?

因为这个项目在笔者的IDEA上运行是正常的,不可能说,放到Linux就挂掉了吧,连mvn clean 都报错。具体错误两个

  • 第一个

spring-boot-starter-parent-2.2.2.RELEASE.pom and ‘parent.relativePath’ points at wrong local POM @ line 30, column 13

  • 第二个

java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -> [Help 2]

按照正常人的思维,我肯定是解决掉第一个再去解决第二个,是吧。

但是呢?笔者花了将近4个小时左右,

  1. 从maven的setting文件,阿里云的镜像,pom依赖是不是有问题
  2. 删掉了parent,重新拉取,还是不行
  3. jdk和maven是不是不匹配,对比了之后,是匹配的
  4. 重新拉了个自己的项目,结果居然爆java.security.InvalidAlgorithmParameterException

所以说排查问题得有思路,正常都是第一个之后再第二个吧,而且英语很重要啊。看security明显的权限问题,一查下去,发现是HTTPS在搞鬼。

后面看到这个帖子

https://www.cnblogs.com/wpbxin/p/11746229.html

上面说的是安全性的问题,有几种解决方法,但是笔者选择了快捷有效的。

直接忽略SSL安全检查,加载mvn package之后。

mvn package -Dmaven.test.skip=true -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

之后运行,OK完成。

解决

绕过前面一大堆思路,看看报错问题是否存在java.security.InvalidAlgorithmParameterException,先把你maven拉取jar包的权限弄好再说。

直接在maven命令上加上忽略SSL安全检查

mvn package -Dmaven.test.skip=true -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

总结

排查思路很重要啊,而且一些maven的常用命令没怎么去学习。最近有些懈怠了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值