【问题标题】:Why can't maven plugin work with eclipse java compiler?为什么maven插件不能与eclipse java编译器一起工作?
【发布时间】:2012-05-21 15:10:43
【问题描述】:

我在 eclipse 中安装了 m2eclipse 插件。我在 eclipse 中有一个 java 项目。然后我将 pom.xml 添加到我的项目的根文件夹中。将我的项目转换为 Maven 项目。现在问题来了:我可以下载 pom.xml 中包含的 jar,但无法将其导入我的 java 文件。 我的项目中总是出现 java 编译错误。在包资源管理器视图中,我可以看到 maven 依赖项。

我试过这个:maven clean,重启eclipse,project clean。

这是我的 pom.xml

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>TomLabs</groupId>
    <artifactId>TomLabs</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>test</name>
    <description>Tom source code</description>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>javax.media</groupId>
            <artifactId>jmf</artifactId>
            <version>2.1.1e</version>
        </dependency>
    </dependencies>
</project>

【问题讨论】:

  • 你可以在外部/从控制台使用 maven 构建项目吗?
  • 我在控制台运行 mvn compile。并发现提取 jar 文件的问题。然后转到本地存储库文件夹,jar文件确实损坏了。但是在 Eclipse 中,我可以扩展该 jar 包,并查看其中的类。所以我被骗了。现在重新下载,问题解决了
  • 酷,另一项工作做得很好;)

标签: eclipse maven pom.xml


【解决方案1】:

一种可能是您尝试导入的包/类在您在 pom.xml 中提到的 jar 文件版本中不可用。

【讨论】:

    猜你喜欢
    • 2016-08-10
    • 2018-12-02
    • 2019-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-28
    • 2021-04-29
    • 2015-03-16
    相关资源
    最近更新 更多