Maven依赖项未正确编译为war包。

huangapple 未分类评论50阅读模式
英文:

maven dependency not properly compile into war

问题

以下是翻译好的内容:

我正在使用 Eclipse IDE,过去我一直在开发一个 Maven 项目,依赖于本地源(来自 github 上的 sap-olingo)以及作为 JAR 加载的 Maven 依赖项。我现在已经更新了 github 的源代码,以及所有的依赖项,但似乎这破坏了标准的 Eclipse 导出功能(右键单击项目 -> 导出 -> WAR)。

当使用 Maven 安装功能时,Web 项目运行良好,并将所有源代码加载到 META-INF/lib 类中,但是当从 Eclipse 导出为 WAR 时(我以前做过),它似乎没有编译一个正确的依赖项。所谓的丢失是指 JAR 仍然存在于 WAR 的 META-INF/lib 目录中,但内容为空,大小仅为 1KB。

将 mvn clean install 与导出版本进行比较,几乎没有什么区别。除了需要在运行时编译的项目。mvn 创建的 WAR 中的库大小与导出的 WAR 大致匹配,除了一个 JAR。

有没有办法找出这个问题的根本原因?我只使用 IDE 集成的 Maven,所以我怀疑 Maven 版本或 JDK 方面是否有差异。
不幸的是,我不知道从何处开始,以及您需要什么信息。

谢谢您的建议。

编辑:
我的项目的 POM 文件:

<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.test</groupId>
  <artifactId>odata</artifactId>
  <packaging>war</packaging>
  <version>4.0.0</version>
  <name>odataMaven Webapp</name>
  <url></url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
	<dependency>
		<groupId>com.sap.olingo</groupId>
		<artifactId>odata-jpa-processor</artifactId>
		<version>0.3.7-SNAPSHOT</version>
	</dependency>
	<dependency>
	    <groupId>com.microsoft.sqlserver</groupId>
	    <artifactId>mssql-jdbc</artifactId>
	    <version>6.1.0.jre8</version>
	</dependency>
	<dependency>
		<groupId>org.eclipse.persistence</groupId>
		<artifactId>javax.persistence</artifactId>
		<version>2.1.0</version>
	</dependency>
	<dependency>
		<groupId>javax.servlet</groupId>
		<artifactId>servlet-api</artifactId>
		<version>2.5</version>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>org.eclipse.persistence</groupId>
		<artifactId>eclipselink</artifactId>
		<version>2.6.2</version>
	</dependency>
  </dependencies>
  <build>
    <finalName>odata</finalName>
	<pluginManagement>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.17</version>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>${project.build.source}</source>
					<target>${project.build.source}</target>
				</configuration>
			</plugin>
		</plugins>
	</pluginManagement>
  </build>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.build.source>1.8</project.build.source>
	</properties>
</project>

odata-jpa-processor 的源代码/项目从 此处 获取。问题仅存在于 olingo-jpa-metadata JAR 中,该 JAR 是空的。所有其他 Maven 依赖项都正确导出。

英文:

I am using the Eclipse IDE and in the past, I have been developing a maven project depending on local sources (from github (sap-olingo)) as well as maven dependencies loaded as jar. I have now updated the github source and also all the dependencies which seems to break standard eclipse export functionalities (right click porject -> export -> war)

The webproject is working fine when using the maven install functionality and is loading all sources into the META-INF/lib classes, but when using the export as war from eclipse (which I did previously) it is missing to compile a proper dependency. Missing in the sense of that the jar is still present in the META-INF/lib directory of the war, but the content is empty and the size is only 1kb

When comparing the mvn clean install to the exported, there are rarely any differences. Except for the projects that are to be compiled during the runtime. Sizes of the libs in the mvn created war and the exported war roughly matches except for that one jar.

Is there a way to root cause that issue? I am using solely the maven integrated into the IDE which is why I doubt differences in the maven versions and or jdk.
Unfortunately I have no idea in where to start and what info you require

Thanks for your input

EDIT:
My projects pom:

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.test&lt;/groupId&gt;
  &lt;artifactId&gt;odata&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;4.0.0&lt;/version&gt;
  &lt;name&gt;odataMaven Webapp&lt;/name&gt;
  &lt;url&gt;&lt;/url&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;3.8.1&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;com.sap.olingo&lt;/groupId&gt;
		&lt;artifactId&gt;odata-jpa-processor&lt;/artifactId&gt;
		&lt;version&gt;0.3.7-SNAPSHOT&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
	    &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
	    &lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
	    &lt;version&gt;6.1.0.jre8&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
		&lt;artifactId&gt;javax.persistence&lt;/artifactId&gt;
		&lt;version&gt;2.1.0&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;javax.servlet&lt;/groupId&gt;
		&lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
		&lt;version&gt;2.5&lt;/version&gt;
		&lt;scope&gt;provided&lt;/scope&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
		&lt;artifactId&gt;eclipselink&lt;/artifactId&gt;
		&lt;version&gt;2.6.2&lt;/version&gt;
	&lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
    &lt;finalName&gt;odata&lt;/finalName&gt;
	&lt;pluginManagement&gt;
		&lt;plugins&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
				&lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
				&lt;version&gt;2.17&lt;/version&gt;
			&lt;/plugin&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
				&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
				&lt;configuration&gt;
					&lt;source&gt;${project.build.source}&lt;/source&gt;
					&lt;target&gt;${project.build.source}&lt;/target&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;
		&lt;/plugins&gt;
	&lt;/pluginManagement&gt;
  &lt;/build&gt;
	&lt;properties&gt;
		&lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
		&lt;project.build.source&gt;1.8&lt;/project.build.source&gt;
	&lt;/properties&gt;
&lt;/project&gt;

The odata-jpa-processor source/project is pulled from here. The problem exists solely with the olingo-jpa-metadata jar which is empty. All other maven dependencies are exported correctly.

huangapple
  • 本文由 发表于 2020年4月8日 13:38:21
  • 转载请务必保留本文链接:https://java.coder-hub.com/61093964.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定