相关文章推荐
听话的硬盘  ·  flask-socketio的connect ...·  3 周前    · 
追风的啤酒  ·  Protocol support for ...·  1 年前    · 
刀枪不入的甘蔗  ·  Python3 ...·  1 年前    · 
越狱的牛肉面  ·  java.sql.SQLException: ...·  1 年前    · 

这里日记一下 关于Maven非常基础的问题: Maven parent.relativePath 的意思,很多人网上搜索 类似下面pom.xml中的问题 ,文件中的

<relativePath /> <!-- lookup parent from repository  --> 

是什么意思?

    <parent>
        <groupId>com.middol</groupId>
        <artifactId>webbase-dependency-management</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

网上大多数回到如下:

设定一个空值将始终从仓库中获取,不从本地路径获取,如<relativePath />
Maven parent.relativePath
默认值为../pom.xml
查找顺序:relativePath元素中的地址–本地仓库–远程仓库

部分 Java 菜鸟或是一部分老鸟竟然也懵逼
答案第一行 :

设定一个空值将始终从仓库中获取,不从本地路径获取,如<relativePath />  

然后又开始问 : 仓库 是哪一个仓库 !?

我就纳闷了搜什么百度,自己测试一下不就好了吗,另外直接点击进去看原生说明啊,下面是 xml 原生英文解释:

      <xs:element name="relativePath" minOccurs="0" type="xs:string" default="../pom.xml">
        <xs:annotation>
          <xs:documentation source="version">4.0.0</xs:documentation>
          <xs:documentation source="description">
            The relative path of the parent &lt;code&gt;pom.xml&lt;/code&gt; file within the check out.
            The default value is &lt;code&gt;../pom.xml&lt;/code&gt;.
            Maven looks for the parent pom first in the reactor of currently building projects, then in this location on
            the filesystem, then the local repository, and lastly in the remote repo.
            &lt;code&gt;relativePath&lt;/code&gt; allows you to select a different location,
            for example when your structure is flat, or deeper without an intermediate parent pom.
            However, the group ID, artifact ID and version are still required,
            and must match the file in the location given or it will revert to the repository for the POM.
            This feature is only for enhancing the development in a local checkout of that project.
          </xs:documentation>
        </xs:annotation>
      </xs:element>

读一读英文,不行字典翻译翻译,然后自己做下实验 得出如下结论:

  1. relativePath 是Maven为了寻找父模块pom.xml所额外增加的一个寻找路径
  2. relativePath 默认值为 …/pom.xml
  3. Maven 寻找父模块pom.xml 的顺序如下:
    (1)  first in the reactor of currently building projects
          这里一个maven概念 反应堆(reactor ),
          意思就是先从工程里面有依赖相关的模块中找你引入的
          parent 的pom.xml,
    (2) then in this location on the filesystem
         然后从 你定义的  <relativePath > 路径中找,
         当然你如果只是 /  即空值,则跳过该步骤,  
         默认值 ../pom.xml 则是从上级目录中找啦。
    (3)  then the local repository
       这个就不说了,如果 (1) (2) 步骤没有则从 本地仓库找啦。
    (4) and lastly in the remote repo
     这个还用说吗,上面都找不到了,最后只能从远程仓库找啦,再找不到就报错给你看 
                    这里日记一下 关于Maven非常基础的问题: Maven parent.relativePath 的意思,很多人网上搜索 类似下面pom.xml中的问题 ,文件中的&lt;relativePath /&gt; &lt;!-- lookup parent from repository  --&gt; 是什么意思?    &lt;parent&gt;        &lt;groupId&...
				
Installing m2eclipse Core To install m2eclipse, use the following Eclipse update site to install the core of the m2eclipse plugin. This Core update site contains a single component: "Maven Integration for Eclipse (Required)". When you install this component you will be installing all of the core Wizards, the POM Editor, Maven Repository integration, and Maven integration m2eclipse Core Update Site: http://m2eclipse.sonatype.org/sites/m2e IMPORTANT NOTE: You cannot upgrade from m2eclipse 0.9.8 or m2eclipse 0.9.9 to m2eclipse 0.10.0. If you are running m2eclipse 0.9.8 or 0.9.9 you must either uninstall m2eclipse from your Eclipse installation or start with a fresh installation of Eclipse. To install this plugin in the Eclipse IDE: Select Help > Install New Software. This should display the "Install" dialog. Paste the Update Site URL into the field named "Work with:" and press Enter. Pressing Enter should cause Eclipse to update list of available plugins and components. Choose the component listed under m2eclipse: "Maven Integration for Eclipse (Required)". Click Next. Eclipse will then check to see if there are any issues which would prevent a successful installation. Click Next and agree to the terms of the Eclipse Public License v1.0. Click Finish to begin the installation process. Eclipse will then download and install the necessary components. Once the installation process is finished, Eclipse will ask you if you want to restart the IDE. Sonatype strongly recommends that you restart your IDE after installing m2eclipse. Note about 0.9.8 Workspace Incompatibility: If you are using m2eclipse 0.10.0 with a workspace that contains projects created under m2eclipse 0.9.8, you must remove the workspaceState.ser file. The workspaceState.ser file is located within the workspace directory in $workspacedir/.metadata/.plugins/org.maven.ide.eclipse/workspaceState.ser. If you remove this file, m2eclipse 0.10.0 will regenerate it as needed.
东西很简单,只是作为一个记录给后面的兄弟。周末搞了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文件,必须要到你项目
There is no nutrition in the blog content. After reading it, you will not only suffer from malnutrition, but also impotence. The blog content is all parallel goods. Those who are worried about being cheated should leave quickly.
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.9.RELEASE</version>
title: SpringBoot学习笔记(创建SpringBoot项目) date: 2020-10-25 14:28:36 SpringBoot学习笔记(创建SpringBoot项目) 创建一个SpringBoot项目; 第一步:创建maven项目;(jar) 1、创建新项目; 2、选择maven项目; 3、填写名字; 4、选择maven自动导入; 5、选择设置; 6、将maven设置为本地配置好的; 第二步、导入SpringBoot相关的依赖; 1、导入依赖; <!--被继承的父项目的版本 --> <version /> <!-- 父项目的pom.xml文件的相对路径。相对路径允许你选择一个不同的路径。默认值是../pom.xmlMaven首先在构建当前项目的地方寻找父项 目的pom,其次在文件系统的这个位置(relativePath位置),然后在本地仓库,最后在远程仓库寻找父项目的pom。 --> <relativePath /> </parent> version。 --> <parent> <!--被继承的父项目的构件标识符 --> <artifactId /> <!--被继承的父项目的全球唯一标识符 --> <groupId />
&lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;1.5.6.RELEAS...
写给新手的SpringBoot完整教程——04SpringBoot数据访问篇一.JDBC与MySQL使用 一.JDBC与MySQL使用 首先使用SpringBoot Initializer来快速创建一个Web项目。 在我们的Pom文件,关键依赖是: <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId>
invalid content was found starting with element '{"http://maven.apache.org/pom/4.0.0":dependency}'. one of '{"http://maven.apache.org/pom/4.0.0":parent, "http://maven.apache.org/pom/4.0.0":packaging, "http://maven.apache.org/pom/4.0.0":name, "http://maven.apache.org/pom/4.0.0":description, "http://maven.apache.org/pom/4.0.0":url, "http://maven.apache.org/pom/4.0.0":prerequisites, "http://maven.apache.org/pom/4.0.0":issuemanagement, "http://maven.apache.org/pom/4.0.0":cimanagement, "http://maven.apache.org/pom/4.0.0":inceptionyear, "http://maven.apache.org/pom/4.0.0":mailinglists, "http://maven.apache.org/pom/4.0.0":developers, "http://maven.apache.org/pom/4.0.0":contributors, "http://maven.apache.org/pom/4.0.0":licenses, "http://maven.apache.org/pom/4.0.0":scm, "http://maven.apache.org/pom/4.0.0":organization, "http://maven.apache.org/pom/4.0.0":build, "http://maven.apache.org/pom/4.0.0":profiles, "http://maven.apache.org/pom/4.0.0":modules, "http://maven.apache.org/pom/4.0.0":repositories, "http://maven.apache.org/pom/4.0.0":pluginrepositories, "http://maven.apache.org/pom/4.0.0":dependencies, "http://maven.apache.org/pom/4.0.0":reports, "http://maven.apache.org/pom/4.0.0":reporting, "http://maven.apache.org/pom/4.0.0":dependencymanagement, "http://maven.apache.org/pom/4.0.0":distributionmanagement, "http://maven.apache.org/pom/4.0.0":properties}' is expected.
无效的内容,以元素'{"http://maven.apache.org/pom/4.0.0":dependency}'开头。其中一个期望的元素是'{"http://maven.apache.org/pom/4.0.0":parent, "http://maven.apache.org/pom/4.0.0":packaging, "http://maven.apache.org/pom/4.0.0":name, "http://maven.apache.org/pom/4.0.0":description, "http://maven.apache.org/pom/4.0.0":url, "http://maven.apache.org/pom/4.0.0":prerequisites, "http://maven.apache.org/pom/4.0.0":issuemanagement, "http://maven.apache.org/pom/4.0.0":cimanagement, "http://maven.apache.org/pom/4.0.0":inceptionyear, "http://maven.apache.org/pom/4.0.0":mailinglists, "http://maven.apache.org/pom/4.0.0":developers, "http://maven.apache.org/pom/4.0.0":contributors, "http://maven.apache.org/pom/4.0.0":licenses, "http://maven.apache.org/pom/4.0.0":scm, "http://maven.apache.org/pom/4.0.0":organization, "http://maven.apache.org/pom/4.0.0":build, "http://maven.apache.org/pom/4.0.0":profiles, "http://maven.apache.org/pom/4.0.0":modules, "http://maven.apache.org/pom/4.0.0":repositories, "http://maven.apache.org/pom/4.0.0":pluginrepositories, "http://maven.apache.org/pom/4.0.0":dependencies, "http://maven.apache.org/pom/4.0.0":reports, "http://maven.apache.org/pom/4.0.0":reporting, "http://maven.apache.org/pom/4.0.0":dependencymanagement, "http://maven.apache.org/pom/4.0.0":distributionmanagement, "http://maven.apache.org/pom/4.0.0":properties}'。