Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven 3工件问题_Java_Eclipse_Struts2_M2eclipse_Maven 3 - Fatal编程技术网

Java Maven 3工件问题

Java Maven 3工件问题,java,eclipse,struts2,m2eclipse,maven-3,Java,Eclipse,Struts2,M2eclipse,Maven 3,我在eclipse中使用struts2 archtype启动器创建了一个新的struts项目 在做任何事情之前,我的项目中已经出现了一些错误。解决了大部分问题,但仍有1个问题给了我一些问题 缺少工件com.sun:tools:jar:1.5.0:system pom.xml 我试图手动将tools.jar添加到我的存储库中,但这并没有解决问题 我的pom看起来像这样 <?xml version="1.0" encoding="UTF-8" ?> <project xmlns=

我在eclipse中使用struts2 archtype启动器创建了一个新的struts项目

在做任何事情之前,我的项目中已经出现了一些错误。解决了大部分问题,但仍有1个问题给了我一些问题

缺少工件com.sun:tools:jar:1.5.0:system pom.xml

我试图手动将tools.jar添加到我的存储库中,但这并没有解决问题

我的pom看起来像这样

<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.divespot</groupId>
    <artifactId>website</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>E-Divespot diving community</name>
    <url>http://www.e-divespot.com</url>
    <description>A website to support divers from all around the world.</description>

    <dependencies>
        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>

        <!--  Struts 2 -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.0.11.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-sitemesh-plugin</artifactId>
            <version>2.0.11.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-spring-plugin</artifactId>
            <version>2.0.11.2</version>
        </dependency>

        <!-- Servlet & Jsp -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- Jakarta Commons -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.1.1</version>
        </dependency>

        <!-- Dwr -->
        <dependency>
            <groupId>uk.ltd.getahead</groupId>
            <artifactId>dwr</artifactId>
            <version>1.1-beta-3</version>
        </dependency>
    </dependencies>

    <build>
      <finalName>website</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                   <source>1.6</source>
                   <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.5</version>
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

4.0.0
com.spot
网站
战争
0.0.1-快照
电子潜水社区
http://www.e-divespot.com
一个支持世界各地潜水员的网站。
朱尼特
朱尼特
4.8.2
测试
org.apache.struts
struts2型芯
2.0.11.2
org.apache.struts
struts2 sitemesh插件
2.0.11.2
org.apache.struts
struts2弹簧插件
2.0.11.2
javax.servlet
servlet api
2.4
假如
javax.servlet
jsp api
2
假如
文件上传
文件上传
1.1.1
英国有限公司
dwr
1.1-beta-3
网站
maven编译器插件
1.6
1.6
org.mortbay.jetty
maven jetty插件
6.1.5
10

您不能使用存储库中的tools.jar

可悲的是,依赖关系树中的某些东西认为您可以。因此,您必须使用“excludes”来摆脱现有的依赖关系,然后用以下内容替换它

如果使下面的版本与错误消息中的版本匹配,则可能不需要“排除”

你需要:

  <profiles>
    <profile>
      <id>default-tools.jar</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>Sun Microsystems Inc.</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>whatever</version>
          <scope>system</scope>
          <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
      </dependencies>
    </profile>

default-tools.jar
java.vendor
太阳微系统公司。
com.sun
工具
无论什么
系统
${java.home}/./lib/tools.jar

您看到的错误可能是因为您没有正确设置JAVA\u主路径。您是否看到类似于
C:\{directories to jre}\..\lib\tools.jar

通过修改eclipse.ini并添加以下内容,可以使用内置JDK启动eclipse

-vm
C:\{directories to JDK}\bin\javaw.exe
我学到的是,eclipse默认情况下将使用您的系统jre来启动eclipse。您可能在启动eclipse时看到过类似于“eclipse在JRE下运行,m2eclipse需要JDK一些插件无法工作”的消息

如果您转到(在eclipse中)Help->Installation Details并查找-vm,您可能会看到它指向的地方没有它所期望的路径结构

注意:无论出于什么原因,当我遇到这个问题时,maven中的java.home都是从eclipse的启动位置进行评估的。因此,当它试图从它所看到的java.home中提取tools.jar时,它可能不是您实际设置为java\u home的env/system变量。


<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>${struts2.version}</version>
    <exclusions>
        <exclusion>
            <artifactId>tools</artifactId>
            <groupId>com.sun</groupId>
        </exclusion>
    </exclusions>
</dependency>
org.apache.struts struts2型芯 ${struts2.version} 工具 com.sun
eclipse.ini的示例:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
C:\Java\JDK\1.6\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx1024m
-vm值:Linux示例:

-vm
/opt/sun-jdk-1.6.0.02/bin/java

From

令人困惑的是,${java.home}属性实际上将从JRE_home环境变量解析其值

(搜索java.home)


如果您不想将JAVA_HOME更改为jre根目录,请创建jre_HOME变量。

sudo apt get install openjdk-7-source

最近出现了同样的问题,上述解决方案中没有一个适合我。我偶然发现并认为这就是这里提到的


我不得不从Eclipse的配置中删除所有已安装的
jre
(窗口->首选项->Java->已安装的jre),只保留一个jdk。在那之后,maven工作得很好,没有对eclipse.ini进行任何修改。这是Ecplise Indigo Service Release 1。需要添加另一个答案。将m2e升级到1.4.20130601-0317后,返回错误。同样,包括我刚才提出的解决方案在内,所有提出的解决方案都不起作用。最终,我发现了罪魁祸首:include
org.htmlparser:1.6
隐含了对
tools.jar
的依赖。不知道为什么删除已安装的jre有助于旧版m2e(1.0.something)。现在的解决方案是排除
tools.jar

    <dependency>
        <groupId>org.htmlparser</groupId>
        <artifactId>htmlparser</artifactId>
        <version>1.6</version>
        <exclusions>
            <exclusion>
                <artifactId>tools</artifactId>
                <groupId>com.sun</groupId>
            </exclusion>
        </exclusions>
    </dependency>

org.htmlparser
HTMLPasser
1.6
工具
com.sun

主要问题是mavan无法调整tool.jar。所以这个问题就出现了 您只需在项目中添加tool.jar文件即可。java软件中的tool.jar文件C:\Program Files\java\jdk1.6.0\u 14\lib
试试这段代码,希望你能成功运行 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 Strust2测试 Strust2测试 0.0.1-快照 战争 org.apache.struts

        <artifactId>Struts2-core </artifactId>
        <version>2.3.15.1</version>
        <exclusions>
    <exclusion>
        <artifactId>tools</artifactId>
        <groupId>com.sun</groupId>
    </exclusion>
</exclusions>
    </dependency>
</dependencies>
<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>
Struts2内核
2.3.15.1
工具
com.sun
src
maven编译器插件
3.1
1.6
1.6
maven战争插件
2.3