java - 使用带有官方 Google Appengine Maven 插件的 Java 7

标签 java google-app-engine maven maven-plugin java-7

I'm having trouble using the official Maven Plugin and Java 7 with Google Appengine.

配置

我的项目配置pom.xml非常简单:

在我配置的属性部分:

<gae.version>1.7.4</gae.version>

后来我使用了这个插件:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.3.2</version>
  <configuration>
    <source>1.7</source>
    <target>1.7</target>
  </configuration>
</plugin>
<plugin>
  <groupId>com.google.appengine</groupId>
  <artifactId>appengine-maven-plugin</artifactId>
  <version>${gae.version}</version>
</plugin>

错误信息

每当我运行 mvn appengine:update 时,我都会收到以下错误:

Unable to update app: The application contains Java 7 classes, but the --use_java7 flag has not been set.

我尝试解决它

当然,我试图解决这个问题。运行

mvn appengine:update --use_java7

mvn appengine:update -D--use_java7

没有帮助,因为该标志未用于 Maven 插件,而是用于 appcfg 脚本。

我如何将标志传递给脚本,以便我可以使用 Java 7(或者我还能做些什么)?

最佳答案

App Engine Java 7 支持目前面向 Trusted Tester,尚未向公众开放,您可以在 here 申请 Trusted Tester .

幸运的是最新的官方maven插件确实实现了这个功能,见AbstractAppCfgMojo.java :

... ...

/**
 * Use the App Engine Java 7 runtime for this app.
 *
 * @parameter
 */
protected boolean useJava7;

... ...

if (useJava7) {
  arguments.add("--use_java7");
}

... ...

您可以在 pom.xml 中使用以下插件配置来启用 Java7 支持:

</build>
  <plugins>
    ... ...
    <plugin>
      <groupId>com.google.appengine</groupId>
      <artifactId>appengine-maven-plugin</artifactId>
      <version>${gae.version}</version>
      <configuration>
        <useJava7>true</useJava7>
      </configuration>
    </plugin>
  </plugins>
</build>

关于java - 使用带有官方 Google Appengine Maven 插件的 Java 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14675058/

相关文章:

Java 8 Stream Mapping 分组操作

java - Scala 中的集合和 toArray

java - 谷歌应用引擎 : how to prevent image resize failure for big images

java - Hibernate - 有没有办法获取违反约束的列的名称?

maven - 我可以控制哪些 Artifact 在 Sonatype Nexus 中可用吗?

java - 鼠标监听器不工作

java - java中的继承 : object state and behavior

google-app-engine - 父/祖先关系的引用属性?

google-app-engine - Google App Engine 模块主机名 : not an App Engine context

java - mvn clean compile 工作但是 mvn install 编译失败