IBM/blockchain-application-using-fabric-java-sdk 启动遇到的

2021/10/10 22:44:16

本文主要是介绍IBM/blockchain-application-using-fabric-java-sdk 启动遇到的,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

首先附上github地址:blockchain-application-using-fabric-java-sdk

我安装readme中的步骤来,把区块链网络跑起来之后,创建channel成功了,安装链码也成功了,只是最后在实例化(instantiate)链码的时候一直失败,提示:

could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 "/chaincode/input/src/github.com/chaincode/farcar.go:37:2: cannot find package “github.com/hyperledger/core/chaincode/shim” in any of:
/usr/local/go/src/github.com/hyperledger/core/chaincode/shim (from $GOROOT)
/chaincode/input/src/github.com/hyperledger/fabric-chaincode-go/shim (from $GOPATH)
/go/src/github.com/hyperledger/fabric-chaincode-go/shim


/chaincode/input/src/github.com/chaincode/pcurd.go:38:6: cannot find package “github.com/hyperledger/fabric/protos/peer” in any of:
/usr/local/go/src/github.com/hyperledger/fabric/protos/peer (from $GOROOT)
/chaincode/input/src/github.com/hyperledger/fabric/protos/peer (from $GOPATH)
/go/src/github.com/hyperledger/fabric/protos/peer"

这里通过2步解决这个问题。

第一步

cd到network_resources/chaincode/src/github.com/fabcar目录下,更改fabcar.go文件import的package,修改后的内容如下:

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"strconv"

    "github.com/hyperledger/fabric-chaincode-go/shim"
     sc "github.com/hyperledger/fabric-protos-go/peer"

)

第二步

 安装go1.13.15,然后执行:

go env -w GO111MODULE=on

把项目clone下来之后,cd到network_resources/chaincode/src/github.com/fabcar目录下,然后执行

go mod init
go mod vendor

然后删掉docker容器,重新跑一遍就好了



这篇关于IBM/blockchain-application-using-fabric-java-sdk 启动遇到的的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程