WEB3J Maven 插件出现问题,找不到 Solidity 编译器

mar*_*100 5 java maven web3-java

我使用 web3j maven 插件自动生成智能合约 Java 代理。

但我有一个问题,找不到 Solidity 编译器版本。

[INFO]
[INFO] --- web3j-maven-plugin:4.8.2:generate-sources (default) @ web3j-client-lib ---
[INFO] Solidity: adding to process 'DZPayments.sol'
[INFO] Solidity: adding to process 'Migrations.sol'
[INFO] Solidity: adding to process 'Proxy.sol'
[INFO] Solidity: adding to process 'Storage.sol'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  26.928 s
[INFO] Finished at: 2021-06-18T10:50:37+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to get solidity version from server
Run Code Online (Sandbox Code Playgroud)

有人有想法吗?

我仅使用默认配置并将 SOL 文件复制到 src/main/resources

这是我的插件配置(最简单的!):

    <plugin>
        <groupId>org.web3j</groupId>
        <artifactId>web3j-maven-plugin</artifactId>
        <version>4.8.2</version>
        <configuration>
            <soliditySourceFiles/>
        </configuration>
    </plugin>
Run Code Online (Sandbox Code Playgroud)

我在 4.8.4 版本中使用了以下两个依赖项,但我也在 5.0.0 版本中对其进行了测试,结果相同:

<dependency>
    <groupId>org.web3j</groupId>
    <artifactId>abi</artifactId>
    <version>4.8.4</version>
</dependency>
<dependency>
    <groupId>org.web3j</groupId>
    <artifactId>core</artifactId>
    <version>4.8.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

小智 3

我们有同样的问题。我们通过手动执行maven插件的一些步骤解决了这个问题:

  1. 转到此处发布的 Solidity 版本列表: https: //internal.services.web3labs.com/api/solidity/versions/
  2. 将显示的 json 保存releases.json~/.web3j/solc/.
  3. 手动搜索二进制文件列表下载您需要的二进制文件(即 win/linux/mac)。
  4. 将选定的二进制文件保存在子文件夹中,并使用版本作为名称。例如,如果您需要版本,0.4.25请创建相应的文件夹 ( ~/.web3j/solc/0.4.25/) 并将二进制文件放在那里。
  5. 重新运行您的 Maven 构建。

不知何故,问题是maven插件无法下载相应的文件。手动执行此操作后,插件会找到二进制文件并跳过下载它们。