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/