【问题标题】:"static interface method invocations are not supported in -source 7" despite using 1.8“-source 7 中不支持静态接口方法调用”尽管使用 1.8
【发布时间】:2021-01-04 12:27:17
【问题描述】:

这是完整的错误信息:

"-source 7 不支持静态接口方法调用 (使用 -source 8 或更高版本来启用静态接口方法调用)"

这是课程:

public class UserVerticle extends AbstractVerticle {

    @Override
    public void start() {
        Router router=Router.router(vertx);//IDE shows error message here
    }

    @Override
    public void stop() {
    }
}

以下是项目属性:

这些是我的依赖项:

        <groupId>io.vertx</groupId>
        <artifactId>vertx-core</artifactId>
        <version>4.0.0</version>

还有:

        <groupId>io.vertx</groupId>
        <artifactId>vertx-web</artifactId>
        <version>3.4.1</version>

编辑

我在 pom.xml 中将 javaee-web-api 版本更改为 8(它是 7),使用依赖项构建,但仍然遇到相同的错误。

编辑2

我在 pom.xml 中将 vertx-web 版本更改为 4.0.0,使用依赖项构建,但仍然遇到相同的错误。

【问题讨论】:

    标签: vert.x vert.x-webclient


    【解决方案1】:

    原来我应该在maven-compiler-plugin中选择source 8,这完全解决了问题:

     <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
    

    【讨论】:

      猜你喜欢
      • 2011-04-03
      • 2019-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-17
      • 1970-01-01
      • 2020-10-21
      • 2021-10-30
      相关资源
      最近更新 更多