我根据this文档创建了一个Google App Engine maven项目,它运行成功。然后我使用选项现有Maven项目将同一个项目导入eclipse。但是在eclipse中它只有maven项目而没有java facet。然后我通过右键单击项目 - >手动添加了facet。属性 - >项目方面 - >勾选java选项。现在eclipse在我创建的应用程序上显示java错误(对于某些与应用程序引擎相关的类)。但是这个项目通过使用maven命令工作正常,例如 mvn clean install 和 mvn appengine:devserver 。以下是我的maven项目的pom
<?xml version="1.0" encoding="UTF-8"?>
<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>com.google.appengine.demos</groupId>
<artifactId>guestbook</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<appengine.target.version>1.9.0</appengine.target.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<module>guestbook-war</module>
<module>guestbook-ear</module>
</modules>
</project>
答案 0 :(得分:1)
您似乎没有任何依赖关系。这些定义了应用程序所依赖的库。最小的是,对于一场内战,你需要这样的事情:
<dependencies>
<!-- Servlet dependencies -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>
<!-- GAE Dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${gae.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
如果您还想进行单元测试,则需要在上面的块中添加以下内容:
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
如果你想在eclipse中工作,请确保安装了wtp-m2e eclipse插件,并安装了Google Plugin for Eclipse插件。他们会让你的生活更轻松。