我已经找了几个小时了,但找不到我要找的东西。我知道 GWT 客户端包不支持 java.io.File。我想在服务器包中使用它。编译应用程序时出现以下错误:
Compiling module com.xxx.yyy.GWTApp
Validating units:
[ERROR] Errors in 'file:/.../workspace/GWTApp/src/com/xxx/yyy/server/Class1.java'
[ERROR] Line 26: No source code is available for type java.io.File; did you forget to inherit a required module?
[ERROR] Errors in 'file:/.../workspace/GWTApp/src/com/xxx/yyy/server/Class2.java'
[ERROR] Line 104: No source code is available for type java.io.BufferedReader; did you forget to inherit a required module?
[ERROR] Line 104: No source code is available for type java.io.FileReader; did you forget to inherit a required module?
...
任何想法可能是错误的?
编辑 *.gwt.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='yyy'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<entry-point class='com.xxx.yyy.client.Yyy'/>
<source path='client'/>
<source path='shared'/>
<source path='server'/>
<inherits name="com.smartgwt.SmartGwt"/>
</module>
最佳答案
从您的 *.gwt.xml
中删除这一行:
<source path='server'/>
source标签用于标识需要编译成javascript的包。不应包括服务器包。
关于java - GWT java.io.File 服务器包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21532776/