使用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>