tencent cloud

Tencent Cloud Blockchain as a Service

Release Notes
Product Introduction
Overview
Product Features
Underlying Engine
Strengths
Scenarios
Basic Concepts
Purchase Guide
Purchase Page Description
Overdue Payment Instructions
Pricing and Specification Description
Getting Started
Hyperledger Fabric
Operation Guide
Consortium
Event Center
Network Overview
Connection Management
Contract Management
Organization Management
Node Management
Blockchain Browser
Certificate management
Audit Log
Node Monitoring and Logs
Development Guide
Hyperledger Fabric
Application System Integration
API Documentation
History
Introduction
API Category
Making API Requests
Hyperledger Fabric 2.3 APIs
Data Types
Error Codes
FAQs
Product Policy
Data Processing And Security Agreement
Contact Us

Contract Package Description

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-04-10 00:41:07
Java language contract sample package, please see fabric-contract-java.

Java Contract Packaging

1. Add the following local repository configuration in the pom.xml file:
<repositories> <repository> <id>my-local-repo</id> <url>file://${project.basedir}/repository</url> <snapshots> <enabled>true</enabled> <updatePolicy>never</updatePolicy> <checksumPolicy>ignore</checksumPolicy> </snapshots> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> <checksumPolicy>ignore</checksumPolicy> </releases> </repository> <repository> <id>central</id> <url>https://repo.maven.apache.org/maven2</url> <snapshots> <enabled>true</enabled> <updatePolicy>never</updatePolicy> <checksumPolicy>ignore</checksumPolicy> </snapshots> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> <checksumPolicy>ignore</checksumPolicy> </releases> </repository> </repositories>
2. Add the following maven plug-in configuration in the pom.xml file. Note that use the specified version.
<build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.1.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <finalName>chaincode</finalName> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>chaincode.example.SimpleChaincode</mainClass> </transformer> </transformers> <filters> <filter> <!-- filter out signature files from signed dependencies, else repackaging fails with security ex --> <artifact>*:*</artifact> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin> </plugins> </build>
3. Add relevant dependencies in the pom.xml. An example is as follows:
<dependencies> <dependency> <groupId>org.hyperledger.fabric-chaincode-java</groupId> <artifactId>fabric-chaincode-protos</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>org.hyperledger.fabric-chaincode-java</groupId> <artifactId>fabric-chaincode-shim</artifactId> <version>2.3.1</version> <exclusions> <exclusion> <groupId>com.github.everit-org.json-schema</groupId> <artifactId>org.everit.json.schema</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.16</version> </dependency> </dependencies>
4. Run the following command to download the contract dependency to the repository directory.
mvn dependency:copy-dependencies -DoutputDirectory=repository -Dmdep.useRepositoryLayout=True -Dmdep.copyPom=True
5. Use the zip -r xxx.zip * command in the contract root directory to pack the contract.


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック