亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何解決 bootcamp-cordapp 中的 NotSerializedException。

如何解決 bootcamp-cordapp 中的 NotSerializedException。

波斯汪 2023-08-16 16:37:54
我正在嘗試運行 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條經驗 獲得超13個贊

Corda 使用自己的序列化框架,該框架要求 Java 編譯器在生成字節碼時保留參數名稱,以便以后可以正確地重新創建對象。

要使其與 IntelliJ 一起使用,請執行以下操作:

  1. 打開設置:

    • Windows:文件 -> 設置

    • osX/Ubuntu:IntelliJ IDEA -> 首選項

  2. 轉到“構建、執行、部署”->“編譯器”->“Java 編譯器”,在“附加命令行參數”字段中寫入參數

https://img1.sycdn.imooc.com//64dc8b1400010a0318421296.jpg

  1. 完全重建項目(Build -> Rebuild Project)

https://img1.sycdn.imooc.com//64dc8b240001f2e602520252.jpg

查看完整回答
反對 回復 2023-08-16
  • 1 回答
  • 0 關注
  • 117 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號