问题
While running a corDapp(corDapp-example) for the first time using Kotlin-source, the IntelliJ throws this error - "error Class 'com.example.NodeDriverKt' not found in module 'cordapp-example". I looked for this class in my project structure and I can see a file named NodeDriver.kt which contains a function "main" but I could not see any class declaration. Any solution to remove this error would be much appreciated.IntelliJ
回答1:
i had this same problem with the example cordapp. I was able to resolve this problem by deleting the build and gradle folders in my project, and then, opening the jet brains IDE back again. This restarted the process of installing the gradle. Then the configurations file were set the right way. Previously all the class paths were not there. Have a look on my new configuration of kotlin that was preset after performing the above step. "Use Classpath of module" now is com.example.workflows-kotlin.test =>
I hope this helps :)
回答2:
A Kotlin file called FileName.kt
with a main
method is compiled into a JVM class called FileNameKt
. So the NodeDriverKt
class is generated when the Kotlin main
method in NodeDriver.kt
is compiled into a JVM class.
This appears to be an IntelliJ caching issue. Try deleting the Run Example CorDapp - Kotlin
run configuration (even if you are not using it directly to run the driver.
回答3:
Solution 1 : It is a problem centric to 'Caching issue' of IntelliJ IDE. Open menu: File
and hit Invalidate Caches / Restart...
.
Solution 2 : If the problem still persists then remove the gradle folder from the project and close the project and after opening the IDE ,it will setup the gradle again.And it will solve the issue. While debugging the application,now you will be able to see the class path.
来源:https://stackoverflow.com/questions/49717001/error-class-com-example-nodedriverkt-not-found-in-module-cordapp-example