【问题标题】:Build Path Issue with Maven Dependencies (jconsole-jdk.jar) [duplicate]Maven依赖项的构建路径问题(jconsole-jdk.jar)[重复]
【发布时间】:2014-10-11 07:07:36
【问题描述】:

我切换到 Wildfly 8.1 并且无法解决这个构建(路径)问题,最终还是受到了 arquillian 测试框架的影响。

pom.xml

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <version.org.jboss.arquillian>1.1.5.Final</version.org.jboss.arquillian>
    <version.org.wildfly>8.1.0.Final</version.org.wildfly>
    <version.junit>4.11</version.junit>
</properties>

<profiles>
    <profile>
        <id>arquillian-jbossas-remote</id>
        <dependencies>
            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-arquillian-container-remote</artifactId>
                <version>${version.org.wildfly}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>${version.org.jboss.arquillian}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.1.4.GA</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.protocol</groupId>
        <artifactId>arquillian-protocol-servlet</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <ejbVersion>3.1</ejbVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>7.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-dependency-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.6,)
                                    </versionRange>
                                    <goals>
                                        <goal>copy</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

错误消息(Eclipse):

容器“Maven Dependencies”引用了不存在的库“C:\Users\user.m2\repository\sun\jdk\jconsole\jdk\jconsole-jdk.jar”

希望有人可以帮助我。

【问题讨论】:

  • 您是否验证了错误消息中提到的jar存在于构建路径上?

标签: java eclipse maven jboss-arquillian


【解决方案1】:

解决方案是将 eclipse vm 更改为 jdk。 Eclipse 使用了 jre - 我也配置了 jdk。

如果其他人有同样的问题,请在 eclipse.ini 中添加以下内容:

-vm 
C:\Program Files\Java\jdk1.7.0_60\bin\javaw.exe

重要

条目必须放在前两行 - 如发布 - 在 eclipse.ini 中! (Eclipse Luna 和可能的其他人)

【讨论】:

  • 最好只指向 bin 文件夹而不是 javaw.exe(参见 stackoverflow.com/questions/8375423/…)。注意:就我而言,正如上述帖子中的评论所建议的那样,在 eclipse 停止抱怨之前,我必须从工作区中删除该项目并再次重新导入它(maven 项目)。希望它可以帮助那些受 eclipse jdk/jre 混淆怪异影响的人。
【解决方案2】:

我遇到了这个问题,将 jdk 添加到 eclipse.ini 并没有解决这个问题。

Eclipse 尝试通过遵循相对于 eclipse jre 路径的路径来解析 jconsole.jar

/../lib/jconsole.jar

Eclipse 默认的 JRE 必须指向 JDK 文件夹内的 JRE,才能解析 jconsole.jar。

在我的情况下,我的 JRE eclipse 指向 C:\Program Files\Java\jre1.8.0_20

正确的应该是 C:\Program Files\Java\jdk1.8.0_20\jre

【讨论】:

    【解决方案3】:

    budha 的解决方案对我不起作用,所以我在 pom 中手动添加了依赖项:

        <dependency>
            <groupId>sun.jdk</groupId>
            <artifactId>jconsole</artifactId>
            <version>1.8</version>
            <scope>system</scope>
            <systemPath>C:\Program Files\Java\jdk1.8.0_60\lib\jconsole.jar</systemPath>
        </dependency>
    

    【讨论】:

      猜你喜欢
      • 2012-02-15
      • 1970-01-01
      • 2012-01-15
      • 1970-01-01
      • 2011-10-29
      • 2012-03-06
      • 1970-01-01
      • 2016-04-19
      • 1970-01-01
      相关资源
      最近更新 更多