将嵌套接口作为泛型类型的类(在 maven 中未找到符号错误,但在 eclipse 中有效)



我有一个奇怪的(或者可能不是)问题。我正在使用 MVP 框架并通过以下方式定义我的一些类:

public class SomePresenter extends 
    Presenter<SomePresenter.MyView, SomePresenter.MyProxy> 
{
    public interface MyView extends View {}
    public interface MyProxy extends Proxy {}
}

在 eclipse 中,这编译得很好(我猜是因为它使用了 eclipse 编译器),但是当我使用 maven(oracle jdk7 或 6)时,我得到一个符号未找到的 View 接口错误。

如果我执行以下操作之一,它可以使用 maven 编译良好:

  • 将接口放在单独的 Java 文件中
  • View 的导入语句移动到导入列表的顶部。

oracle java编译器中使用嵌套接口作为泛型类型是否存在已知问题?

我不

认为这是Oracle编译器的问题,只是为了确保您可以尝试在Eclipse中使用它?

更有可能的是,我认为这是一个依赖问题 - 请向我们展示您的 POM 文件?另外,复制具体的编译错误。

View接口在com.gwtplatform:gwtp-mvp-client工件中定义,该工件应该在某处。你说如果你把视图import to the top of the import list - is there another视图'移到你可能需要摆脱的地方,它会起作用(Ctrl-Shift-O 用于"优化导入"在 Eclipse 中很方便)。

干杯

在你的POM中试试这个。关键部分是依赖部分。它将使用 eclipse 编译器。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <compilerArgument>-proc:none</compilerArgument>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-compiler-eclipse</artifactId>
            <version>1.8.2</version>
        </dependency>
    </dependencies>
</plugin>

最新更新