我正在尝试运行 Contract 的 corda-bootcamp 测试用例。我按照视频中给出的方式进行操作,但是当尝试运行合同测试时 - 我收到错误java.io.NotSerializableException: data(net.corda.core.contracts.ContractState) -> Trying to build an object serializer for bootcamp.TokenState, but it is not constructible from its public properties, and so requires a custom serialiser.有人可以帮忙吗,如何解决这个问题?我发现了类似的问题-here ,但这不起作用。下面是使用的 Tokenstate,package bootcamp;import com.google.common.collect.ImmutableList;import net.corda.core.contracts.BelongsToContract;import net.corda.core.contracts.ContractState;import net.corda.core.identity.AbstractParty;import net.corda.core.identity.Party;import java.util.ArrayList;import java.util.List;/* Our state, defining a shared fact on the ledger. * See src/main/java/examples/ArtState.java for an example. */@BelongsToContract(TokenContract.class)public class TokenState implements ContractState { private Party issuer; private Party owner; private int amount; public TokenState(Party issuer, Party owner, int amount) { this.issuer = issuer; this.owner = owner; this.amount = amount; } public Party getIssuer() { return issuer; } public Party getOwner() { return owner; } public int getAmount() { return amount; } public List<AbstractParty> getParticipants() { List<AbstractParty> participants = new ArrayList<>(); participants.add(issuer); participants.add(owner); return participants; }}
1 回答
红颜莎娜
TA贡献1842条经验 获得超12个赞
Corda 使用自己的序列化框架,该框架要求 Java 编译器在生成字节码时保留参数名称,以便以后可以正确地重新创建对象。
要使其与 IntelliJ 一起使用,请执行以下操作:
打开设置:
Windows:文件 -> 设置
osX/Ubuntu:IntelliJ IDEA -> 首选项
转到“构建、执行、部署”->“编译器”->“Java 编译器”,在“附加命令行参数”字段中写入参数
完全重建项目(Build -> Rebuild Project)
添加回答
举报
0/150
提交
取消