使用web3j-maven-plugin插件编译solidity源文件编译错误
cd D:\GitHub\web3j; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_161" M2_HOME=D:\\apache-maven-3.6.3 cmd /c "\"\"D:\\apache-maven-3.6.3\\bin\\mvn.cmd\" -Dmaven.ext.class.path=D:\\NetBeans82\\java\\maven-nblib\\netbeans-eventspy.jar -Dfile.encoding=UTF-8 web3j:generate-sources\""
Scanning for projects...
-------------------------< com.acuilab:web3j >--------------------------
Building web3j 1.0-SNAPSHOT
--------------------------------[ jar ]---------------------------------
## --- web3j-maven-plugin:4.5.11:generate-sources (default-cli) @ web3j ---
Adding to process 'FC.sol'
Adding to process 'FCPausable.sol'
Adding to process 'FCRoles.sol'
Adding to process 'IFC.sol'
Solidity Compiler found
Solidity Compiler from library is used
## BUILD FAILURE
## Total time: 2.923 s
Finished at: 2020-08-15T15:30:15+08:00
Failed to execute goal org.web3j:web3j-maven-plugin:4.5.11:generate-sources (default-cli) on project web3j: Could not compile solidity source file. Version mismatch. -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
发现环境变量设置了solidity-windows路径

当前d:\solidity-windows目录下的solc版本是
D:\solidity-windows>solc --version
solc, the solidity compiler commandline interface
Version: 0.6.10+commit.00c0fcaf.Windows.msvc
而solidity源文件版本是这样的
pragma solidity ^0.5.0;
这条pragma编译版本控制指令表示:
源文件将既不允许低于 0.5.0 版本的编译器编译, 也不允许高于(包含) 0.6.0 版本的编译器编译(第二个条件因使用 ^ 被添加)。
这种做法的考虑是,编译器在 0.6.0 版本之前不会有重大变更,所以可确保源代码始终按预期被编译。 上面例子中不固定编译器的具体版本号
,因此编译器的补丁版也可以使用。
ok,下载如下版本并加入环境变量中

下载地址:https://github.com/ethereum/solidity/releases/tag/v0.5.17