Unable to import sumCashBy using IntelliJ IDEA

五迷三道 提交于 2020-04-30 13:56:31

问题


IntelliJ IDEA started highlighting errors in some of my import statements that worked previously. This is not unexpected as net.corda.finance is still in the "incubating" stage.

I am working in Java.

Corda Release: 3.3

Noticed this change on github: https://github.com/corda/corda/pull/4700

So I made what I thought are the necessary changes...

//Old

//import static net.corda.finance.utils.StateSumming.sumCashBy;

//New

import static net.corda.finance.contracts.utils.StateSumming.sumCashBy;

...but I'm still getting an error. I am sure I must be overlooking something simple.


回答1:


@Kid101 put me on the right track by trying StateSumming.sumCashBy(contractState)

Once I did that IntelliJ recognized I needed to add:

net.corda:corda-finance:3.3-corda 

...to the classpath. If I allowed IntelliJ to add it from the context menu the error reappeared every time gradle refreshed. So I added:

cordaCompile "$corda_release_group:corda-finance:$corda_release_version"

...to the build.gradle file under the dependencies section. No more errors with my import statement:

import net.corda.finance.utils.StateSumming;

...and no issues calling the sumCashBy method.




回答2:


The change you mention is in Corda master branch, In CashTests.kt you can see how sumCashBy is imported, import net.corda.finance.contracts.utils.sumCashBy.

In corda/release-V4-branchpoint import is still net.corda.finance.utils.sumCashBy i.e. the change has not made in yet to V4.

Try to build the project again.

If using Java, try: StateSumming.sumCashBy(contractState)



来源:https://stackoverflow.com/questions/54601576/unable-to-import-sumcashby-using-intellij-idea

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!