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

时间:2014-08-18 11:22:21

标签: java eclipse maven jboss-arquillian

我切换到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):

  

容器&#39; Maven Dependencies&#39;引用非现有库&#39; C:\ Users \ user.m2 \ repository \ sun \ jdk \ jconsole \ jdk \ jconsole-jdk.jar&#39;

希望有人可以帮助我。

3 个答案:

答案 0 :(得分:15)

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

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

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

重要

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

答案 1 :(得分:10)

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

Eclipse尝试通过遵循相对于eclipse jre path

的路径来解析jconsole.jar

/../ LIB / jconsole.jar

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

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

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

答案 2 :(得分:3)

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

/