eclipse Maven 依赖项的构建路径问题 (jconsole-jdk.jar)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25362127/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:53:52  来源:igfitidea点击:

Build Path Issue with Maven Dependencies (jconsole-jdk.jar)

javaeclipsemavenjboss-arquillian

提问by budha

I switched to Wildfly 8.1 and can not resolve this build (path) problem, which somehow is eventually influenced by arquillian test framework.

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

pom.xml:

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>

Errormessage(Eclipse):

错误消息(Eclipse):

The container 'Maven Dependencies' references non existing library 'C:\Users\user.m2\repository\sun\jdk\jconsole\jdk\jconsole-jdk.jar'

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

Hope somebody can help me.

希望有人可以帮助我。

回答by budha

Solution was to change eclipse vm to jdk. Eclipse used jre - also I configured jdk.

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

If somebody else has the same problem, add following in eclipse.ini:

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

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

Important:

重要

The entry has to be placed in first two lines - as posted - in eclipse.ini!!! (Eclipse Luna and possibly others)

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

回答by jbhardwaj

I ran across this issue and adding jdk to eclipse.ini did not solve this problem.

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

Eclipse tries to resolve jconsole.jar by following path relative to eclipse jre path

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

/../lib/jconsole.jar

/../lib/jconsole.jar

Eclipse default JRE must point to JRE inside of JDK folder, so it can resolve jconsole.jar.

Eclipse 默认的 JRE 必须指向 JDK 文件夹内的 JRE,因此它可以解析 jconsole.jar。

In my case my JRE eclipse was pointing to C:\Program Files\Java\jre1.8.0_20

就我而言,我的 JRE eclipse 指向 C:\Program Files\Java\jre1.8.0_20

Correct should have been C:\Program Files\Java\jdk1.8.0_20\jre

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

回答by negstek

budha's solution doesn't work for me so I manually add the dependency in the pom:

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>