scala的trait执行报错: 错误: 找不到或无法加载主类 cn.itcast.scala.`trait`

Posted mediocreworld

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scala的trait执行报错: 错误: 找不到或无法加载主类 cn.itcast.scala.`trait`相关的知识,希望对你有一定的参考价值。

scala的trait执行报错:

错误: 找不到或无法加载主类 cn.itcast.scala.`trait`.Children

原因:包名写成了trait,与trait关键字重名了:

package cn.itcast.scala.`trait`


解决方法:将包名trait修改为其他名字,比如traits

 

以上是关于scala的trait执行报错: 错误: 找不到或无法加载主类 cn.itcast.scala.`trait`的主要内容,如果未能解决你的问题,请参考以下文章

Scala在通用特征方法中找不到案例类参数

Product.scala trait 中 productPrefix def 的实际使用

一些编译错误

Scala 学习之「trait 」

找不到'Carbon Traits ObjectInitialisation'laravel5.8

Scala编程入门---面向对象编程之Trait高级知识