pom.xml文件上出现一个红叉,它显示了依赖项中缺少的工件

时间:2019-06-08 09:35:23

标签: maven pom.xml

我已经开始从事maven一个项目的工作。构建项目后,我的pom.xml文件上出现一个红叉,如何解决依赖关系问题?

我已经尝试按照某些答案中的说明将球衣版本更改为1.8和1.19.1,但是即使在重新啮合后十字架也没有前进。

    <dependencies>                              // showing error
          <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-servlet</artifactId>
        <version>1.8</version>
    </dependency>
    <dependency>                       //showing error
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>${jersey.version}</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>                   //showing error
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>${jersey.version}</version>
        <scope>test</scope>
    </dependency>

2 个答案:

答案 0 :(得分:0)

在“项目资源管理器”视图中右键单击顶级项目(而不是pom.xml文件)。 从菜单中,选择Maven>更新项目。 确保已选中“强制更新快照/发行版”,然后单击“确定”。 您将在应用程序窗口的右下角看到一个进度指示器。更新完成后,您应该能够正常生成代码,并且错误标记应该消失。

答案 1 :(得分:0)

我在pom.xml中的标签下面添加了标签,问题已解决。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M4</version>
            <configuration>
                <includes>
                    <exclude>**/*RunnerNew2.java</exclude>
                </includes>
            </configuration>
        </plugin>

    </plugins>

</build>