jar的POM无效,传递依赖性将不可用

时间:2017-09-18 09:48:59

标签: eclipse maven dependencies pom.xml

我想在eclipse中为我的maven项目提供外部依赖。因此,我将jar文件及其POM.xml直接复制到本地Maven资源库中。但不知何故,Eclipse抱怨jar的POM无效。

我在本地存储库中的jar文件的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>

  <parent>
    <groupId>com.b.t</groupId>
    <artifactId>v-parent</artifactId>
    <version>3.9.0</version>
  </parent>

  <scm>
        <developerConnection>scm:svn:url/</developerConnection>
    </scm>

  <artifactId>v-p</artifactId>
  <version>1.1.0</version>
  <name>p</name>
  <build>
    <plugins>
      <!-- Plugin required to build java classes from XSD using XJC -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
          <execution>
            <id>xjc</id>
            <goals>
              <goal>xjc</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <arguments>-npa</arguments>
          <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
          <packageName>com.b.t.v.fusion.p.generated</packageName>
          <schemaFiles>pConfig.xsd</schemaFiles>
          <outputDirectory>${basedir}/target/generated-sources</outputDirectory>
        </configuration>
      </plugin>
    </plugins>
    <pluginManagement>  
      <plugins>      
        <!-- Plugin required to add the generated sources to the classpath -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.8</version>
          <executions>
            <execution>
              <phase>generate-sources</phase>
              <goals>
                <goal>add-source</goal>
              </goals>
              <configuration>
                <sources>
                  <source>${basedir}/target/generated-sources</source>
                </sources>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>  
  </build>


  <dependencies> 
      <dependency>
        <groupId>com.b.t</groupId>
        <artifactId>v-fusioninterface</artifactId>
      </dependency> 
      <dependency>
        <!-- FFT -->
        <groupId>com.github.wendykierp</groupId>
        <artifactId>JTransforms</artifactId>
        <version>3.1</version>
      </dependency>
      <dependency>
        <!-- Reading and writing of MATLAB files -->
        <groupId>net.sourceforge.jmatio</groupId>
        <artifactId>jmatio</artifactId>
        <version>1.0</version>
      </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
      </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <profiles>
  <profile>
    <id>doclint-java8-disable</id>
    <activation>
      <jdk>[1.8,)</jdk>
    </activation>

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <configuration>
            <additionalparam>-Xdoclint:none</additionalparam>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles> 
</project>

我已经检查了类似的帖子并在eclipse.ini中做了必要的更改(将JDK的JRE指定为vmargs n all)。我对MAven项目的依赖性如下所示:

<dependency>
            <groupId>com.b.t</groupId>
            <artifactId>v-p</artifactId>
            <version>1.1.0</version>
        </dependency>

请注意,相同的jar文件和相应的POM.xml对我的Intellij同事来说非常有用。

我正在使用Eclipse Luna来获取信息。我还在Eclipse中检查过Installed JRE是jdk1.8.0_144。

当我在命令提示符下使用mvn clean install时,我也遇到了同样的错误。

有人可以建议我可以查看更多内容吗?

1 个答案:

答案 0 :(得分:1)

您不能只将文件复制到本地仓库,而是需要安装它们。这里有说明:https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

在你的情况下会是这样的:

//This is an example. This should be added when the user seen the dialog.
//This is just a Bootstrap example. Just to demonstrate the logic.
$("#modal-dialog").on("shown.bs.modal", function(){
  localStorage.setItem("IS_SET", true);
});

$("#modal-dialog").on("hidden.bs.modal", function(){
  localStorage.setItem("IS_SET", false);
});

$(document).ready(function(){
  if(localStorage.getItem("IS_SET") && localStorage.getItem("IS_SET") === true){
     //Which means the user was in the form process.
     //And show the modal again on page refresh.
     $("#modal-dialog").modal("show");
  }
});
相关问题