编程语言
首页 > 编程语言> > IBM/blockchain-application-using-fabric-java-sdk 启动遇到的

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容器,重新跑一遍就好了

标签:src,github,java,fabric,chaincode,blockchain,go,com
来源: https://blog.csdn.net/qq_34039868/article/details/120693442