【发布时间】:2015-02-28 09:41:03
【问题描述】:
我意识到在 StackOverflow 上已多次提出非常相似或相同的问题,但大多数(如果不是全部)似乎最终都有不同的解决方案。
我已经尝试了从此处和其他地方发布的类似问题中找到的几乎所有内容,但我仍然无法让 Maven 将依赖项 JAR 放入 WEB-INF/lib 中。
最奇怪的是,每次我运行 Maven -> Update Project 时,Maven 似乎都将类输出文件夹重新配置为 /target/classes,而不是 Google Web 应用插件所需的 /war/WEB-INF/classes。
在构建路径中的 Maven 依赖项下一切都正确显示,但在 WEB-INF/lib 中没有显示任何内容,因此应用程序在运行时失败并出现 ClassNotFoundExceptions。
这里是 pom.xml 的相关部分:
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<webXml>war/WEB-INF/web.xml</webXml>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
<version>RELEASE</version>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
我必须在 M2E 设置中配置什么吗?我需要使用 Maven 终端命令吗?除了手动管理所有依赖项之外,我真的不知所措(请...不)。
【问题讨论】:
-
您似乎没有按照Importing a Maven Project 的说明进行操作,因为您尚未指定 appengine-maven-plugin 配置。
-
我一定错过了。我在
下添加了它,但它并没有解决问题。由于某种原因,Maven -> 更新项目也仍然恢复使用 /target/classes。 -
您的项目可能未正确设置为 maven。检查您的 Web 项目 -
Properties > Deployment Assembly中是否将 Maven 依赖项设置为部署到WEB-INF/lib。
标签: java google-app-engine maven jakarta-ee classpath