简体   繁体   English

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

[英]I have added dependency in Pom.xml but Maven is not picking up, maven build gets fails

I need to use gson jar for saving a POJO file to java.For this I added its dependency in Pom.xml 我需要使用gson jar将POJO文件保存到java。为此我在Pom.xml中添加了其依赖项

在此处输入图片说明

I have this jar in my local m2 repository 我的本地M2存储库中有这个jar

在此处输入图片说明

But in import statement I am getting this error 但是在导入语句中,我收到此错误 在此处输入图片说明 在此处输入图片说明

I did update project and clean project but didn't resolved the issue. 我确实更新了项目并清理了项目,但没有解决问题。

I then added this jar through add external jar 然后我通过添加外部罐子添加了这个罐子 在此处输入图片说明

With this the compilation error got resolved 有了这个编译错误得到解决 在此处输入图片说明

But when I do Maven install and Maven build it gets failed, the error I am getting is: 但是当我执行Maven安装和Maven构建时,它失败了,我得到的错误是:

在此处输入图片说明

It is giving error on import statement, for Gson. 对于Gson,它在import语句中给出了错误。

Adding the updated pom.xml 添加更新的pom.xml 在此处输入图片说明

pom.xml 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>

Can anyone please suggest what I am missing or how should i resolve this error 任何人都可以建议我所缺少的内容或如何解决此错误

You got wrong dependency declared. 您声明了错误的依赖关系。 It should be 它应该是

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

while your groupId is <groupId>com.google.code.gson.gson</groupId> - notice double .gson at the end. 而您的groupId<groupId>com.google.code.gson.gson</groupId> -请注意在末尾有双.gson

UPDATE: 更新:

So as you have pasted your POM now we can see what is the problem. 因此,现在您粘贴了POM即可看到问题所在。 You have given dependency (gson) in Dependency Managemet not in Dependencies . 您在Dependency Managemet中没有在Dependencies中给出了依赖项(gson)。 You have to include it in Dependencies as well. 您还必须将其包括在Dependencies中。 To understand what dependency management is, read mavens doc https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html 要了解什么是依赖管理,请阅读Mavens文档https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

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

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