[英]How to get the class of a trait within an object defined in scala from within a java class?
我有一個類似於以下內容的Scala對象:
object MyConfig {
@PropertyManagerSources(Array("my.properties"))
trait MyConfigOwner extends PropertyManagerConfig {
@Key("my.key")
def getSomething(): Boolean
}
這是使用所有者來管理屬性。
我正在嘗試像這樣的java類中訪問特征:
import com.bah.cr.common.config.MyConfig.MyConfigOwner;
public class MyJavaClass{
MyConfigOwner config = PropertyManagerConfig Factory.create(MyConfigOwner.class);
}
但是,我收到MyConfig不存在的錯誤。
提前致謝。
事實證明這可行。 我的問題是scala類程序包中的錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.