Maven 3 神器问题
我使用 struts2-archtype-starter 在 eclipse 中创建了一个新的 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>
I made a new struts project in eclipse using the struts2-archtype-starter.
A few errors where in my project already before doing anything. Solved most of them but there is 1 the still give me some problems.
Missing artifact com.sun:tools:jar:1.5.0:system pom.xml
I tried to add the tools.jar to my repository manually but that didn't solve the issue.
My pom looks like this
<?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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
您看到的错误可能是因为您没有正确设置 JAVA_HOME 路径。您是否看到类似
C:\{directories to jre}\..\lib\tools.jar
的内容?您可以通过更改 eclipse.ini 并添加类似内容来使用内置 JDK 启动 eclipse。
据我所知,eclipse 默认情况下将使用您的系统 jre 来启动 eclipse。您可能在启动 eclipse 时看到一条类似于“Eclipse 在 JRE 下运行,m2eclipse 需要 JDK,某些插件将无法工作”的消息,
如果您转到(在 eclipse 中)帮助 ->安装详细信息并查找 -vm,您可能会看到它指向不具有所需路径结构的某个位置。
注意:无论出于什么原因,当我遇到这个问题时,maven 中的 java.home 是从 eclipse 启动的位置进行评估的。因此,当它尝试从它所看到的 java.home 中提取 tools.jar 时,它可能不是您实际设置为 JAVA_HOME 作为环境/系统变量的内容。
The error you are seeing is probably because you dont have your JAVA_HOME path set up correctly. Are you seeing something like
C:\{directories to jre}\..\lib\tools.jar
?You can have eclipse start up using your built in JDK by altering the eclipse.ini and adding something like
What I have learned is that eclipse by default will use your system jre to start eclipse. You probably have seen a message when starting eclipse similar to "Eclipse is running under a JRE and m2eclipse requires a JDK some plugins will not work"
If you go to (in eclipse) Help -> Installation Details and look for a -vm you will probably see it pointing to somewhere that does not have the path structure that it is expecting.
Note: For whatever reason when I encountered this issue java.home in maven was evaluated from where eclipse was launched from. So when it tries to pull the tools.jar from what it sees as java.home it may not be what you actually set as JAVA_HOME as an env/system variable.
您不能使用存储库中的tools.jar。
遗憾的是,您的依赖树中的某些内容认为您可以。因此,您必须使用“排除”来摆脱现有的依赖关系,然后将其替换为以下内容。
如果您使下面的版本与错误消息中的版本匹配,则可能不需要“排除”。
您需要:
You can't use tools.jar from a repository.
Sadly, something in your dependency tree thinks that you can. So, you have to use an 'excludes' to get rid of the existing dependency, and then replace it with the following.
If you make the version in the below match that in the error message, you might not need the 'excludes'.
You need:
需要添加另一个答案。将 m2e 升级到 1.4.20130601-0317 后,错误又回来了。同样,所提出的解决方案都不起作用,包括我刚刚提出的解决方案。最终,我找到了罪魁祸首:包括
org.htmlparser:1.6
对tools.jar
有隐式依赖。不知道为什么删除已安装的 jre 对旧的 m2e(1.0.something)有帮助。现在的解决方案是排除tools.jar
:Need to add another answer. After upgrading m2e to 1.4.20130601-0317 the error came back. Again, none of the proposed solutions worked including the one I just proposed. Eventually, I found the culprit: including
org.htmlparser:1.6
had an implicit dependency ontools.jar
. No idea why deleting the installed jre's helped with the older m2e (1.0.something). Now the solution is to excludetools.jar
:最近遇到了同样的问题,上述解决方案都不适合我。我遇到了 http://blog.samratdhillon.com/archives/598 并认为这是那里提到的Eclipse bug。
我必须从 Eclipse 的配置中删除所有已安装的 jre(Window -> Preferences -> Java -> Installed JRE),并且只保留一个 jdk。之后,maven 就可以正常工作,无需对 eclipse.ini 或其他任何内容进行任何修改。这是 Ecplise Indigo 服务版本 1 中的内容。
Having had the same problem recently none of the above solutions worked for me. I came across http://blog.samratdhillon.com/archives/598 and figured this to be the Eclipse bug mentioned there.
I had to delete all installed
jre
's from Eclipse's configuration(Window -> Preferences -> Java -> Installed JREs)
and only keep exactly one jdk. After that maven worked just fine without any modification toeclipse.ini
or anything else. This is with Ecplise Indigo Service Release 1.eclipse.ini 示例:
-vm 值:Linux 示例:
来自 在此处输入链接描述
The example of eclipse.ini:
-vm value: Linux Example:
From enter link description here
令人困惑的是,${java.home}属性实际上将从JRE_HOME环境变量解析其值。
http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide (搜索 java .home)
如果您不想将 JAVA_HOME 更改为 jre 根目录,则创建 JRE_HOME 变量。
Confusingly the ${java.home} property actually will resolve its value from the JRE_HOME environment variable.
http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide (search for java.home)
If you don't want to change JAVA_HOME to the jre root then create the JRE_HOME variable instead.
主要问题是mavan无法精细化tool.jar。所以出现这个问题
你只需在你的项目中添加tool.jar文件即可。Java软件中存在Tool.jarC:\Program Files\Java\jdk1.6.0_14\lib
尝试这个代码我希望你成功运行
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
信信2测试
信信2测试
0.0.1-快照
战争
org.apache.struts
The Main Problem is that the mavan can not fine the tool.jar. so this problem occurs
u just add tool.jar file in your project .The Tool.jar present in you java software C:\Program Files\Java\jdk1.6.0_14\lib
try this code i hope you run successfully
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
Strust2Testing
Strust2Testing
0.0.1-SNAPSHOT
war
org.apache.struts
sudo apt-get install openjdk-7-source
sudo apt-get install openjdk-7-source