我想使用 Maven 创建一个 App Engine 项目,如下所述:https ://developers.google.com/appengine/docs/java/tools/maven 但遇到一些问题。
mvn -v
输出
Maven home: D:\Shared\apache-maven-3.0.5\bin\..
Java version: 1.7.0_13, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_13\jre
Default locale: de_AT, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
和
mvn archetype:generate
也可以按预期工作,但是当我进入时
com.google.appengine.archetypes:guestbook-archetype
之后没有任何反应,这意味着它再次提示“选择一个数字或应用过滤器[..] ”。
但是,我可以使用来自问题Maven GAE archetype not working的修改命令创建一个项目,即:
mvn archetype:generate -DarchetypeGroupId=com.google.appengine.archetypes -DarchetypeArtifactId=guestbook-archetype -DarchetypeVersion=1.7.7
输出是:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [com.google.appengine.ar
chetypes:guestbook-archetype:1.7.7] found in catalog remote
然后它让我定义 4 个属性的 4 个值,然后打印几行也声明[INFO] BUILD SUCCESS
.
但是,当我然后切换到目录(cd a
在此示例中使用)并运行mvn verify
或mvn appengine:devserver
以下测试失败时:
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.526 sec
Results :
Failed tests: testDoGet(a.GuestbookServletTest): expected:<Hello, test[]
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.826s
[INFO] Finished at: Sun May 05 21:47:32 CEST 2013
[INFO] Final Memory: 14M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
10:test (default-test) on project a: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Shared\maven-projects\a\target\surefire-reports for t
he individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
在文件中D:\Shared\maven-projects\a\target\surefire-reports\a.GuestbookServletTest.txt
,我注意到以下内容:
junit.framework.ComparisonFailure: expected:<Hello, test[]
> but was:<Hello, test[
]
>
作为十六进制,它是
6a 75 6e 69 74 2e 66 72 61 6d 65 77 6f 72 6b 2e 43 6f 6d 70 61 72 69 73 6f 6e 46 61 69 6c 75 72 65 3a 20 65 78 70 65 63 74 65 64 3a 3c 48 65 6c 6c 6f 2c 20 74 65 73 74 5b 5d 0a 3e 20 62 75 74 20 77 61 73 3a 3c 48 65 6c 6c 6f 2c 20 74 65 73 74 5b 0d 5d 0a 3e
如您所见,在实际输出中0d
,方括号之间有一个字符。在预期中,方括号之间没有任何内容。我查了一下,好像是回车。
我应该怎么办?这可能是我的平台存在的问题Cp1252
吗UTF-8
?
我还尝试生成项目设置file.encoding
,例如
mvn archetype:generate -DarchetypeGroupId=com.google.appengine.archetypes -DarchetypeArtifactId=guestbook-archetype -DarchetypeVersion=1.7.7 -Dfile.encoding="UTF-8"
乃至
mvn archetype:generate -DarchetypeGroupId=com.google.appengine.archetypes -DarchetypeArtifactId=guestbook-archetype -DarchetypeVersion=1.7.7 -Dfile.encoding="Cp1252"
但输出中仍然有那个 exta0d
字符。
如果有人能帮助我让它工作,我将不胜感激。