【问题标题】:How to add .jar file dependencies to pom.xml file using m2eclipse plugin如何使用 m2eclipse 插件将 .jar 文件依赖项添加到 pom.xml 文件
【发布时间】:2014-01-05 12:54:55
【问题描述】:

我想将 junit 4.10 添加到我的 pom.xml 的依赖项以及找到的其他 2 个依赖项 https://code.google.com/p/google-gson/downloads/list 在这里https://code.google.com/p/mnist-tools/downloads/detail?name=mnist-tools.zip&can=2&q=

但我不知道如何使用 m2eclipse 插件将它们添加到 pom.xml 文件中

我的 maven 项目的文件结构也可以在这里找到:https://github.com/quinnliu/WalnutiQ

我想知道我的文件结构是否会出现问题?我确实将我所有的测试类命名为 *Test.java 例如 ExampleClass.java 有一个相应的文件 ExampleClassTest.java

到目前为止,这是我的 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>WalnutiQ</groupId>
  <artifactId>WalnutiQ</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <testSourceDirectory>tests</testSourceDirectory>
    <resources>
      <resource>
        <directory>train</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
      <resource>
        <directory>images</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>tests</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source/>
          <target/>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

【问题讨论】:

标签: maven dependencies maven-plugin pom.xml m2eclipse


【解决方案1】:

Gson 在 maven 中可用,因此您只需添加一个依赖项,请参阅 http://search.maven.org/#artifactdetails|com.google.code.gson|gson|2.2.4|jar,它具有您的 pom 所需的 sn-p。

如果 mnist-tools 不在任何地方的 maven 存储库中,您可以使用 mvn install-file 将其添加到本地存储库中。

您的结构可能看起来可以工作(您告诉我们,是吗?),但除非有充分的理由更改它,否则请坚持使用 maven 使用的默认结构。 IE。 src/main/javasrc/main/resourcessrc/test/java 等。如果我添加更多内容,我通常会尝试将它们保持在相同的结构中,例如src/main/scripts

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-14
    • 2014-01-09
    • 1970-01-01
    • 1970-01-01
    • 2014-06-20
    • 2011-01-13
    相关资源
    最近更新 更多