我想使用Maven创建一个App项目,如下所述: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原型不工作中的修改命令创建一个项目,即:
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"但是输出中仍然存在exta 0d字符。
如果有人能帮我把这件事办好,我将不胜感激。
发布于 2013-05-06 14:25:22
结果发现,JUnit测试中存在一个bug。
必须将GuestbookServletTest.java中的行GuestbookServletTest.java更改为:
assertEquals("Hello, " + currentUser.getNickname() + "\n", stringWriter.toString());至
assertEquals("Hello, " + currentUser.getNickname() + System.getProperty("line.separator"), stringWriter.toString());因为Windows使用\r\n作为路径分隔器。我在https://code.google.com/p/googleappengine/issues/detail?id=9272提交了一份bug报告,以防有人感兴趣。
发布于 2013-05-05 21:34:26
请在您的pom.xml中添加以下行,您能试一试吗?
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<maven.compile.encoding>UTF-8</maven.compile.encoding>
</properties> 您可以按照这线程进行类似的讨论。
https://stackoverflow.com/questions/16388709
复制相似问题