1

我对 Maven 非常陌生。我收到以下错误

 The following artifacts could not be resolved: stax:stax:jar:1.0, stax:stax-ri:jar:1.0, clover:clover:jar:1.3-rc4: Failure to find stax:stax:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

经过一些研究(例如NetBeans:使用 -e 开关重新运行 Maven / PluginResolutionException),据说我需要编辑我的~/.m2/settings.xml文件。

我查看了文件,但看不到要更改的内容。因此,我将其包括在下面以供输入:

设置.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
User-specific configuration for maven. Includes things that should not
be distributed with the pom.xml file, such as developer identity, along with
local settings, like proxy information. The default location for the
settings file is ~/.m2/settings.xml
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!--proxies>
    <proxy>
        <host>my.proxy.host</host>
    </proxy>
</proxies-->

<!--pluginGroups>
    <pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups-->

POM.xml

<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.schoolsupplies.v5</groupId>
<artifactId>com.schoolsupplies.v5.test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>com.schoolsupplies.v5.test</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.14</version>
        <scope>test</scope>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jettison</groupId>
        <artifactId>jettison</artifactId>
        <version>1.1</version>
        <scope>test</scope>
        <type>jar</type>
    </dependency>
  <dependency>
    <groupId>dom4j</groupId>
    <artifactId>dom4j</artifactId>
    <version>20040902.021138</version>
    <type>jar</type>
  </dependency>
</dependencies>

4

2 回答 2

0

我有同样的错误。我将存储库添加到 pom.xml 中,一切正常。

像这个例子:

<repositories>
  <repository>
    <id>bukkit-repo</id>
    <url>http://repo.bukkit.org/content/groups/public/</url>
  </repository>
<repositories>
于 2013-01-06T16:58:57.863 回答
0

我打开依赖项目录并删除所有出现问题的 jars——尤其是因为它们没有在pom.xml文件中明确调用。之后,一切正常。

maven 似乎决定我的一些显式导入的依赖项需要这些文件。在我的情况下:stax:stax-ri:jar:1.0,clover:clover:jar:1.3-rc4等。

于 2012-10-13T23:10:43.587 回答