java - Maven 3 工件问题

标签 java eclipse struts2 m2eclipse 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>

最佳答案

您看到的错误可能是因为您没有正确设置 JAVA_HOME 路径。您是否看到类似 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 中)帮助 -> 安装详细信息并查找 -vm,您可能会看到它指向的地方没有预期的路径结构。

注意:无论出于何种原因,当我遇到这个问题时,maven 中的 java.home 是从 eclipse 的启动位置进行评估的。因此,当它尝试从它所看到的 java.home 中提取 tools.jar 时,它可能不是您实际设置为 JAVA_HOME 作为环境/系统变量的内容。

关于java - Maven 3 工件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5756299/

相关文章:

java - 将项目导入 Eclipse 后文件夹困惑

struts2 - 特定的通配符模式在我的 struts.xml 中不起作用

javascript - Struts2:在没有 JavaScript 的情况下根据下拉值自动填充字段

java - 异常 java.lang.OutOfMemoryError : GC overhead limit exceeded with tree map

java - Vaadin 树形网格条件格式

java - 是否可以通过java中的反射更改默认的初始字段值?

linux - 自动完成在 Eclipse 中根本不起作用

java - 使用 GitHub Java API 检索有关登录用户的信息?

java - 'pure' MVC 实现有多有用?

java - 我需要在每个星期五显示一条 toast 消息