繁体   English   中英

是什么导致了“构造函数未定义”之类的错误

[英]what causes the error like “ the constructor is undefined”

我正在尝试在 Eclipse 中编译“Mahout in Action”的示例代码。 有一个名为“LimitedMemoryDiffStorage.java”的 java 文件。 本质上只是定义了一个 class

class LimitedMemoryDiffStorage {

Recommender buildRecommender(DataModel model) throws TasteException {
  DiffStorage diffStorage = new MemoryDiffStorage(
    model, Weighting.WEIGHTED, true, 10000000L);
  return new SlopeOneRecommender(
    model, Weighting.WEIGHTED, Weighting.WEIGHTED, diffStorage);
 }

}

但是 eclipse 编译器声明

构造函数 MemoryDiffStorage(DataModel, Weighting, boolean, long) 未定义

我认为它是在 mahout-core 库中定义的并且已经包含在构建路径中,为什么它仍然会导致这种错误?

也许您使用的库版本与书中描述的版本不同。 很多时候,某些方法、构造函数甚至类都被更改甚至删除了。 检查这一点的最佳方法是检查 mahout-core 库的来源,或者至少检查字节码。 要查看 Eclipse 中包含构造函数的方法,请通过按 CTRL + SHIFT + T 并键入 class 名称来打开特定的MemoryDiffStorage class。 然后在大纲视图中,您应该会看到带有签名的实际构造函数。

According to the documentation at https://builds.apache.org/job/Mahout-Quality/javadoc/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.html the MemoryDiffStorage constructor requires three parameters but you正在通过它四。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM