我在eclipse中使用struts2-archtype-starter创建了一个新的struts项目。
在做任何事情之前,我的项目中已经有一些错误。解决了大部分问题,但仍有1个问题。
Missing artifact 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>发布于 2011-04-22 22:26:41
您看到的错误可能是因为您没有正确设置JAVA_HOME路径。你看到类似C:\{directories to jre}\..\lib\tools.jar的东西了吗?
您可以使用内置的JDK来启动eclipse,方法是修改eclipse.ini并添加如下内容
-vm
C:\{directories to JDK}\bin\javaw.exe我所了解到的是,默认情况下,eclipse将使用您的系统jre来启动eclipse。您可能已经在启动eclipse时看到过类似于"Eclipse is running is a JRE and m2eclipse要求使用JDK某些插件将无法工作“之类的消息
如果您转到(在eclipse中) Help -> Installation Details并查找-vm,您可能会看到它指向的某个位置没有它所期望的路径结构。
注意:无论出于什么原因,当我遇到这个问题时,maven中的java.home都是从启动eclipse的位置进行评估的。因此,当它试图将tools.jar从它看到的java.home中拉出时,它可能不是您实际设置为JAVA_HOME的环境/系统变量。
发布于 2011-09-15 20:22:05
<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>发布于 2011-04-22 22:14:08
您不能从存储库中使用tools.jar。
不幸的是,你的依赖树中的一些东西认为你可以。所以,你必须使用'excludes‘来摆脱现有的依赖,然后用下面的代码替换它。
如果您使下面的版本与错误消息中的版本匹配,您可能不需要'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>
https://stackoverflow.com/questions/5756299
复制相似问题