【发布时间】:2018-02-26 19:34:10
【问题描述】:
我想在 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>
请注意,具有相应 POM.xml 的相同 jar 文件对我在 Intellij 的同事运行良好。
我使用 Eclipse Luna 只是为了获取信息。我还在我的 Eclipse 中检查了已安装的 JRE 是 jdk1.8.0_144。
当我在命令提示符下使用 mvn clean install 时,我也遇到了同样的错误。
有人可以建议我可以检查更多吗?
【问题讨论】:
-
你能在浏览器或任何其他 XML 解析程序中打开 pom.xml 文件吗?
-
是的,我可以用notepad++打开它..
-
notepad++ 是否进行 XML 验证?这与能够查看文件不同。如果您不知道这是什么,请了解一下。
-
对不起..我只是试图用 Internet Explorer 打开它,但似乎无法用它打开它,看来..你在 xml 编辑器中打开它有什么疑问?你认为这不是正确的 xml 文件吗?
-
如果 Internet Explorer 无法打开它,因为它是一个损坏的 xml 文件,它说明了您的问题。您必须修复 XML 以使其有效。
标签: eclipse maven dependencies pom.xml