简体   繁体   English

Maven,继承pom模块

[英]Maven, Inherit pom module

I am writing a project but I encountered a problem compiling my project.我正在编写一个项目,但在编译我的项目时遇到了问题。 After I imported the necessary dependencies, as shown on the pom file, I couldnt run the project.在我导入必要的依赖项后,如pom文件所示,我无法运行该项目。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>


  <artifactId>universeBySali-web</artifactId>
  <packaging>war</packaging>

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

    <properties>
        <java.version>13.0.2</java.version>
     </properties>

    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
            <version>15.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sali</groupId>
            <artifactId>universeBySali-ui</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>

        <build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>

The error that it shows on the pom file is as follows:在pom文件上显示的错误如下:

Project build error: 'parent.relativePath' of POM org.springframework.boot:universeBySali-web:1.3.6.RELEASE (C:\\Users\\User\\Desktop\\Materiale\\Desktop\\Java Projects\\universeBySali\\universeBySali-web\\pom.xml) points at com.sali:universeBySali instead of org.springframework.boot:spring-boot-starter-parent, please verify your project structure项目构建错误:'parent.relativePath' of POM org.springframework.boot:universeBySali-web:1.3.6.RELEASE (C:\\Users\\User\\Desktop\\Materiale\\Desktop\\Java Projects\\universeBySali\\universeBySali-web\\pom .xml) 指向 com.sali:universeBySali 而不是 org.springframework.boot:spring-boot-starter-parent,请验证您的项目结构

This pom file has a parent pom as shown below:这个 pom 文件有一个父 pom,如下所示:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.sali</groupId>
  <artifactId>universeBySali</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <modules>
    <module>universeBySali-Model</module>
    <module>universeBySali-repository</module>
    <module>universeBySali-service</module>
    <module>universeBySali-util</module>
    <module>universeBySali-web</module>
    <module>universeBySali-ui</module>
  </modules>
</project>

Can somebody tell me what I am doing wrong??有人能告诉我我做错了什么吗?? Thanks谢谢

By default Maven assumes the parent has the following relativePath: ../pom.xml .默认情况下,Maven 假定父级具有以下相对../pom.xml../pom.xml Maven will try to match match the groupId/artifactId/version, if it doesn't succeed a warning is thrown and an "external" parent is used. Maven 将尝试匹配 groupId/artifactId/version,如果它不成功,则会抛出警告并使用“外部”父级。 To ensure Maven won't try to solve the parent as part of your multimodule, you should add <relativePath/> to the parent.为确保 Maven 不会尝试将父级解析为多模块的一部分,您应该将<relativePath/>添加到父级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM