Static methods in interface require -target:jvm-1.8 Web3j.build(httpService)

使用web3j构建项目时,提示如下错误:

Error:(21, 16) Static methods in interface require -target:jvm-1.8
    Web3j.build(httpService)

 在idea中选择scala编译时,带上参数-target:jvm-1.8

 

或者在pom文件中

1) 如果使用 maven-scala-plugin 这个插件编译的,则如下 <arg>-target:jvm-1.8</arg>

 <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <version>2.15.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scalaVersion>${scala.version}</scalaVersion>
                    <args>
                        <arg>-target:jvm-1.8</arg>
                    </args>
                </configuration>
            </plugin>

2)如果使用的是 scala-maven-plugin,则添加的是 <addScalacArgs>-target:jvm-1.8</addScalacArgs>

            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>4.5.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scalaVersion>${scala.version}</scalaVersion>
                    <addScalacArgs>-target:jvm-1.8</addScalacArgs>
                </configuration>
            </plugin>

 

posted @ 2021-07-23 15:22  硅谷工具人  阅读(265)  评论(0编辑  收藏  举报
成功之道,在于每个人生阶段都要有不同的目标,并且通过努力实现自己的目标,毕竟人生不过百年! 所有奋斗的意义在于为个人目标实现和提升家庭幸福,同时能推进社会进步和国家目标! 正如古人讲的正心诚意格物致知,修身齐家治国平天下。