无法将pom依赖项导入另一个

时间:2017-06-18 09:52:40

标签: java maven maven-3 pom.xml

我创建了一个pom文件,其中包含一些我希望用于项目的常见依赖项。 pom有一个pom类型的包装。我已将它推送到我的nexus存储库:https://oss.sonatype.org/service/local/repositories/snapshots/content/com/gwidgets/gwt-spring-boot-starter/1.0-SNAPSHOT/gwt-spring-boot-starter-1.0-20170526.141419-3.pom,现在我正在尝试将其导入其他项目,但maven无法解析依赖关系。这是完整的pom:

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>


    <name>demo</name>
    <description>Demo project</description>

        <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.gwidgets</groupId>
            <artifactId>gwt-spring-boot-starter</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

    <dependencies>
      <dependency>
         <groupId>com.gwidgets</groupId>
         <artifactId>gwt-spring-boot-starter</artifactId>
         <version>1.0-SNAPSHOT</version>
          <type>pom</type>
            <scope>import</scope>
      </dependency> 
      <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
    </dependencies>

        <repositories>
        <repository>
            <id>snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp</directory>
                        </resource>
                    </webResources>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
                <executions>
                    <execution>
                        <id>war</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>war</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


</project>

我尝试添加dependencyManagement部分,没有任何运气。我错过了什么吗?这是maven不允许的吗?任何帮助都会很棒。以下是我在尝试进行GWT编译时遇到的错误:

package com.google.gwt.core.client does not exist
cannot find symbol: class EntryPoint

这只是意味着依赖关系不在那里。

1 个答案:

答案 0 :(得分:0)

回答我自己的问题:在做了一些研究之后,除非使用父pom,否则似乎无法导入pom并使用Maven传递其依赖关系。在我当前的设置中,项目已经有父pom,因此唯一的解决方案是将所有依赖项复制粘贴到目标pom中。将来在Maven中使用此功能会很不错。