我在Pom.xml中添加了依赖项,但是Maven没有提升,maven构建失败了

时间:2016-10-04 07:30:29

标签: java xml eclipse maven

我需要使用gson jar将POJO文件保存到java。为此我在Pom.xml中添加了它的依赖

enter image description here

我的本​​地m2存储库中有这个jar

enter image description here

但在import语句中我收到此错误 enter image description here enter image description here

我确实更新了项目和清理项目,但没有解决问题。

然后我通过添加外部jar添加了这个jar enter image description here

这样就解决了编译错误 enter image description here

但是当我做Maven安装和Maven构建它失败时,我得到的错误是:

enter image description here

对于Gson,它在import语句中给出了错误。

添加更新的pom.xml enter image description here

的pom.xml

<?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>

    <parent>
        <artifactId>parent</artifactId>
        <groupId>configurator</groupId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../parent-pom/pom.xml</relativePath>
    </parent>

    <groupId>com.csc.fs.accel.browser</groupId>
    <artifactId>com.csc.fs.accel.browser.dictionary.rest</artifactId>
    <packaging>bundle</packaging>

    <name>com.csc.fs.accel.browser.dictionary.rest Blueprint Bundle</name>
    <description>com.csc.fs.accel.browser.dictionary.rest OSGi blueprint bundle project.</description>

    <dependencies>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.csc.fs.accel.browser</groupId>
            <artifactId>com.csc.fs.accel.browser.dictionary.service</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>javax.jcr</groupId>
            <artifactId>jcr</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.birt.runtime</groupId>
            <artifactId>org.eclipse.emf.common</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.birt.runtime</groupId>
            <artifactId>org.eclipse.emf.ecore</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.birt.runtime</groupId>
            <artifactId>org.eclipse.emf.ecore.xmi</artifactId>
        </dependency>

        <!-- <dependency>
            <groupId>org.emfjson</groupId>
            <artifactId>emfjson-jackson</artifactId>
            <version>0.9.0</version>
        </dependency> -->
      <dependency>
        <groupId>org.eclipselabs</groupId>
            <artifactId>org.eclipselabs.emfjson</artifactId>
            <version>0.8.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.csc.fs</groupId>
            <artifactId>com.csc.fs.storage.service</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.csc.fs.pa</groupId>
            <artifactId>com.csc.fs.pa.common.exception</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.csc.fs.pa</groupId>
            <artifactId>com.csc.fs.pa.common.service</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.csc.fs.accel</groupId>
            <artifactId>com.csc.fs.accel.etools.datadictionary.model</artifactId>
            <version>2.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.csc.fs.accel</groupId>
            <artifactId>com.csc.fs.accel.etools.common.usability.api</artifactId>
            <version>2.0.0-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.csc.fs.accel</groupId>
            <artifactId>com.csc.fs.accel.etools.common.model</artifactId>
            <version>2.1.0-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
        </dependency>

         <dependency>
                <groupId>org.eclipse.xsd</groupId>
                <artifactId>xsd</artifactId>
                <version>2.2.3</version>
            </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
        </dependency>

        <dependency>
                <groupId>com.csc.fs.pa</groupId>
                <artifactId>
                    com.csc.fs.pa.allowedValue.service
                </artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.7</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Export-Package>com.csc.fs.accel.browser.dictionary.rest*;version=${project.version}</Export-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.csc.fs.accel</groupId>
                <artifactId>
                    com.csc.fs.accel.etools.datadictionary.model
                </artifactId>
                <version>2.0.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>com.csc.fs.accel</groupId>
                <artifactId>com.csc.fs.accel.etools.common.usability.api</artifactId>
                <version>2.0.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>com.csc.fs.accel</groupId>
                <artifactId>
                    com.csc.fs.accel.etools.common.model
                </artifactId>
                <version>2.1.0-SNAPSHOT</version>
            </dependency>
            <dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.7</version>
</dependency>       
</dependencies>
    </dependencyManagement>

</project>

任何人都可以建议我缺少什么或如何解决此错误

1 个答案:

答案 0 :(得分:3)

您声明了错误的依赖项。它应该是

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.7</version>
</dependency>

当您的groupId<groupId>com.google.code.gson.gson</groupId>时 - 请注意最后加倍.gson

<强>更新

因此,当您粘贴POM时,我们可以看到问题所在。 您已在依赖关系管理中提供了依赖关系(gson),而不是依赖关系。您还必须将其包含在依赖关系中。要了解依赖关系管理的内容,请阅读mavens doc https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html