当我编译我的GWT时,我开始遇到一个奇怪的错误。它只会在某个时候发生。
[java] [ERROR] Line 62: Type mismatch: cannot convert from element type Object to SomeClass
和文件中的第62行看起来像这样
for (SomeClass ans : someAutobeanInterface.getSomeClasses()) {
和someAutobeanInterface.getSomeClasses()
List<SomeClass> getSomeClasses();
someAutobeanInterface是一个GWT AutoBean接口。
我正在使用gwt版本2.5.0
我使用ant来编译gwt。
<target name="fetch-gwt-dev">
<echo>Setting up GWT-dependencies</echo>
<artifact:dependencies filesetId="gwt-dev.dependencies.classpath">
<dependency groupId="com.google.gwt" artifactId="gwt-dev" version="2.5.0" />
<dependency groupId="com.bradrydzewski" artifactId="gwt-cal" version="0.9.3.1" />
<dependency groupId="com.google.gwt.google-apis" artifactId="gwt-visualization" version="1.0.2" />
</artifact:dependencies>
<artifact:dependencies filesetId="gwt-user.dependencies.classpath">
<dependency groupId="com.google.gwt" artifactId="gwt-user" version="2.5.0" />
<dependency groupId="javax.validation" artifactId="validation-api" version="1.0.0.GA" classifier="sources" />
</artifact:dependencies>
</target>
<macrodef name="compilegwtappfast" >
<!-- XXX This macro is kind of strange since it depends on the target fetch-gwt-dev to have been run -->
<attribute name="package" />
<attribute name="fakepackage" />
<attribute name="outputdir" />
<!-- The number of workers -->
<attribute name="numberOfWorkers" />
<!-- If the app needs some additional entry on the classpath (such as GWT-Widgets, that should be added here) -->
<element name="additional-classpath" optional="true" />
<sequential>
<echo>Compiling GWT app @{package} and putting it in @{outputdir}</echo>
<echo>Compiling package: @{fakePackage}</echo>
<!-- This directory isn't in SVN so it's not a problem if it doesn't exist -->
<delete description="Cleaning compiler output directory" failonerror="false">
<fileset dir="@{outputdir}">
<include name="**"/>
</fileset>
</delete>
<java fork="true" classname="com.google.gwt.dev.Compiler" failonerror="true">
<classpath>
<fileset refid="gwt-user.dependencies.classpath" />
<fileset refid="gwt-dev.dependencies.classpath" />
<filelist dir="${basedir}">
<file name="src/main/java/" />
</filelist>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg line="-localWorkers @{numberOfWorkers}" />
<arg line="-war @{outputdir}"/>
<arg value="@{fakepackage}" />
</java>
<copy todir="@{outputdir}" description="Move the compiler-output to it's right location" failonerror="true">
<fileset dir="@{outputdir}/@{package}/">
<include name="**" />
</fileset>
</copy>
<delete dir="@{outputdir}/@{package}">
</delete>
<tstamp>
<format property="DONE_COMPILING" pattern="yyyy-MM-dd HH:mm:ss"/>
</tstamp>
<echo>Done compiling GWT-app: ${DONE_COMPILING}</echo>
</sequential>
</macrodef>
<target name="compile-gwt" depends="fetch-gwt-dev">
<compilegwtapp package="my.gwt.package" outputdir="${basedir}/src/main/webapp/mygwt/" numberOfWorkers="4"/>
</target>
有任何关于如何解决这个问题的想法?
答案 0 :(得分:0)
在eclipse中,Java编译器合规性设置可能出现问题。它们可能设置为不允许1.5+语法。