Offline installation and instantiation fabric java chaincode
demand
hyperledger fabric due to its own characteristics, mainly used in large state-owned enterprises and banks, its deployment environment is generally isolated from the external network. If the deployment docker, docker mirror can be by introducing, in the installation and the need to download the corresponding instantiated dependency, and 1.4 environments, Fabric chain code required to instantiate the shadowJar plug.
solution
Solutions can be found online at present is to modify javaenv mirrored dockerfile, it will depend shadowJar plug directly loaded when generating javaenv image file. I found the time to regenerate javaenv image file will be missing some files at the time of this test method, resulting in the generated image is not available.
Reference article addresses: http://www.bubuko.com/infodetail-3024199.html
So I decided to direct all depend copy to the project directory:
build.gradle
document content:
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.3'
id 'java'
}
group 'org.hyperledger.fabric-chaincode-java'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
//chaincode需要的依赖
//compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.1'
//https://mvnrepository.com/artifact/com.alibaba/fastjson
//compile group: 'com.alibaba', name: 'fastjson', version: '1.2.62'
//testCompile group: 'junit', name: 'junit', version: '4.12'
//从项目的libs目录加载依赖的jar包
compile fileTree(dir:'libs',includes:['*.jar'])
}
shadowJar {
baseName = 'chaincode'
version = null
classifier = null
manifest {
attributes 'Main-Class': 'org.hyperledger.fabric.example.SimpleChaincode'
}
}
//将依赖的jar包导入到项目的libs目录下
task copyJars(type: Copy) {
from configurations.runtime
into 'libs' // 目标位置
}
Use gradle build copyJars
command item dependent jar package into the libs directory.