Google App Engine DEFAULT_ENCODING fails in local

2019-06-23 16:38发布

Following Instructions detailed here: https://developers.google.com/appengine/docs/java/config/appconfig#System_Properties_and_Environment_Variables To set the Default Encoding to UTF-8 like so:

<env-variables>
  <env-var name="DEFAULT_ENCODING" value="UTF-8" />
</env-variables>

Throws the following exception:

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)

I have tried this:

-DDEFAULT_ENCODING=UTF-8

And this:

-Dfile.encoding=UTF-8

On the server launch configuration and

JAVA_TOOLS_OPTIONS=-Dfile.encoding=UTF-8 -DDEFAULT_ENCODING=UTF-8

I'm using Windows 8 pro and Intellij Ultimate

Please help

3条回答
ら.Afraid
2楼-- · 2019-06-23 17:05

I had the same problem. Solved it by creating the following Enviroment Variable: DEFAULT_ENCODING=UTF-8

The part:

<env-variables>
  <env-var name="DEFAULT_ENCODING" value="UTF-8" />
</env-variables>

is not needed in your appengine-web.xml

Bonus help in case it is needed: https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them

查看更多
The star\"
3楼-- · 2019-06-23 17:22

I had the same issue on a Mac, and running the following line:

export DEFAULT_ENCODING="UTF-8"

before starting the local server fixed it.

Unfortunately, I'm not sure what the equivalent command in Windows is.

查看更多
闹够了就滚
4楼-- · 2019-06-23 17:24

Windows Environment variables can be set from:

Control Panel->All Control Panel Items->System->Environment Variables

Variable: DEFAULT_ENCODING Value: UTF-8

You will need to restart your IDE after setting the value.

查看更多
登录 后发表回答