【问题标题】:NetBeans: Re-run Maven with the -e switch on / PluginResolutionExceptionNetBeans:使用 -e 开关重新运行 Maven / PluginResolutionException
【发布时间】:2012-03-30 22:36:55
【问题描述】:

我对 Maven 和 Netbeans 一无所知, 我更新了我的 netbeans,现在我的测试不再工作了:

Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed    to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact    org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo1.maven.org/maven2): pr-dfs-bank-   00.emea.isn.corpintra.net: Unknown host pr-dfs-bank-00.emea.isn.corpintra.net -> [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.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

如何使用 netbeans 激活 -e 或 -X 开关,我看到了许多带有“mvn clean”等的示例,但是我通过 Netbeans 安装了 Maven,所以我没有将它放在命令行文件夹中。 我没有收到错误消息,想查看更详细的日志。

我在我的代码中搜索了错误消息中提到的这个 pr-dfs-bank-00.emea.isn.corpintra.net,但它不是我的源代码的一部分。

我的 pom.xml,它应该是 Maven2 和 Selenium

<?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>
    <version>1.0</version>

    <repositories>
        <repository>
          <id>central</id>
          <name>Maven Repository Switchboard</name>
          <layout>default</layout>
          <url>http://repo1.maven.org/maven2</url>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <name>Maven Plugin Repository</name>
          <url>http://repo1.maven.org/maven2</url>
          <layout>default</layout>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <releases>
            <updatePolicy>never</updatePolicy>
          </releases>
        </pluginRepository>
    </pluginRepositories> 

    <properties>
        <maven.build.timestamp.format>yyMMdd-HHmm</maven.build.timestamp.format>
        <project.build.sourceEncoding>windows-1252</project.build.sourceEncoding>
        <lfadapter>${project.basedir}/../lib/lf_CAdapter-4.0.jar</lfadapter>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.3.1</version>
            <scope>test</scope>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.17.0</version>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-ie-driver</artifactId>
            <version>2.17.0</version>
        </dependency>

        <dependency> 
            <groupId>org.apache.poi</groupId> 
            <artifactId>poi-ooxml</artifactId> 
            <version>3.8-beta5</version> 
        </dependency>        

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testSourceDirectory>src/</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <failOnError>false</failOnError>
                    <debug>true</debug>
                    <verbose>true</verbose>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <showDeprecation>true</showDeprecation>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12</version>
                <configuration>
                    <disableXmlReport>false</disableXmlReport>
                    <forkMode>always</forkMode>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <failIfNoTests>false</failIfNoTests>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <workingDirectory>reports/${maven.build.timestamp}/</workingDirectory>
                    <reportsDirectory>reports/surefire/</reportsDirectory>
                    <reporting>
                        <plugins>
                            <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-surefire-report-plugin</artifactId>
                                <version>2.12</version>
                            </plugin>
                        </plugins>
                    </reporting>
                    <properties>
                        <property>
                            <name>showSuccess</name>
                            <value>true</value>
                        </property>
                    </properties>
                    <suiteXmlFiles>
                        <suiteXmlFile>testng-suite.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>netbeans-private-testng</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>netbeans.testng.action</name>
                </property>
            </activation>
        </profile>
    </profiles>
</project>

我认为我的 pom.xml 并不是它应该的样子:(

任何帮助表示赞赏:)

【问题讨论】:

  • 第一个问题:为什么要在 pom 中定义存储库?你不应该那样做。您应该使用您在 pom 中重新定义的默认值,此外您应该使用存储库管理器。为什么要重新定义 testSources 文件夹?不使用约定?您已经通过属性定义了编码,该属性将自动由多个插件(如 maven-site-plugin 等)使用。因此,只定义您真正需要定义的非默认值。为什么要更改存储库目录,因为默认是目标/站点...我可以推荐使用。
  • 你为什么要为 maven-surefire 定义一个执行?它已经绑定到一个阶段,因此无需单独定义它。使用约定! (Maven 的范式是:约定优于配置!)。
  • 你在代理后面吗?
  • @khmarbaise:我不在代理后面。我从示例中复制粘贴了 pom.xml,但我使用了您的建议并相应地进行了更改:)
  • 您是在 Netbeans 中使用嵌入式 Maven 还是对 Maven 的外部调用?您是否检查了 settings.xml 或它的外观?

标签: exception netbeans maven-2 selenium pom.xml


【解决方案1】:

NetBeans 6.9.1 - Mac OS X

要通过 Netbeans 激活您需要的开关,请转到 Preferences --> Miscellaneous --> Maven,然后在 Global Execution Options 下输入以下内容:

--debug --errors

NetBeans - Windows

在 NetBeans(从 7.3 以上版本)中向 Maven 添加调试和错误,如下所示:

  1. 点击工具
  2. 点击选项
  3. 点击 Java 图标。
  4. 点击Maven标签。
  5. 附加到全局执行选项--debug --errors
  6. 点击确定

Maven 将执行包含调试和错误信息的应用程序。

【讨论】:

  • 谢谢,已经找到了,是工具-选项-杂项。 - Maven... :)
  • 如果我想为特定项目设置开关怎么办?我运气不好?
【解决方案2】:

您很可能在 maven 的 settings.xml 文件之一中定义了镜像或代理(例如,在 ~/.m2/settings.xml 中)并且定义错误?喜欢指向错误的服务器?

【讨论】:

  • 我们两个人在使用 Netbeans 8.+ 时遇到了同样的问题,我们使用的是 Windows 操作系统。在我们的C:\Users\[yourUserName]\.m2 文件夹中没有 settings.xml。还有其他选择吗?
【解决方案3】:

在 Netbeans 8.0.2 中,您可以在项目属性->Actions 上定义它 然后选择要在其中指定要传递的参数的操作

【讨论】:

    【解决方案4】:

    在 netbeans 8.2 上, 工具>选项>(见下图)

    1. 在搜索框中输入“maven”
    2. 在“全局...”中键入“--debug --errors”。

    【讨论】:

      猜你喜欢
      • 2011-10-14
      • 2016-11-10
      • 1970-01-01
      • 2020-01-06
      • 1970-01-01
      • 2012-05-12
      • 2023-03-11
      • 2011-04-10
      • 2013-05-08
      相关资源
      最近更新 更多