此处详细说明了以下说明: https://developers.google.com/appengine/docs/java/config/appconfig#System_Properties_and_Environment_Variables 像这样将默认编码设置为 UTF-8:
<env-variables>
<env-var name="DEFAULT_ENCODING" value="UTF-8" />
</env-variables>
抛出以下异常:
com.google.appengine.tools.development.EnvironmentVariableChecker$IncorrectEnvironmentVariableException: One or more environment variables have been configured in appengine-web.xml that have missing or different values in your local environment. We recommend you use system properties instead, but if you are interacting with legacy code that requires specific environment variables to have specific values, please set these environment variables in your environment before running. [Mismatch environmentVariableName=DEFAULT_ENCODING environmentVariableValue=null appEngineWebXmlValue=UTF-8 appEngineWebXmlFile=C:\xxx\out\artifacts\yyy_war_exploded\WEB-INF\appengine-web.xml] at com.google.appengine.tools.development.EnvironmentVariableChecker.check(EnvironmentVariableChecker.java:75)
我试过这个:
-DDEFAULT_ENCODING=UTF-8
还有这个:
-Dfile.encoding=UTF-8
在服务器启动配置和
JAVA_TOOLS_OPTIONS=-Dfile.encoding=UTF-8 -DDEFAULT_ENCODING=UTF-8
我正在使用 Windows 8 专业版和 Intellij Ultimate
请帮忙
最佳答案
我遇到了同样的问题。 通过创建以下环境变量解决它: DEFAULT_ENCODING=UTF-8
部分:
<env-variables>
<env-var name="DEFAULT_ENCODING" value="UTF-8" />
</env-variables>
在您的 appengine-web.xml 中不需要
额外的帮助以备不时之需: https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them
关于java - Google App Engine DEFAULT_ENCODING 在本地环境 Java 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18722336/