是什么导致了类似“”的错误构造函数未定义”
我正在尝试在 Eclipse 中编译“Mahout in Action”的示例代码。有一个名为“LimitedMemoryDiffStorage.java”的 java 文件。本质上只是定义一个类
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 库中定义的并且已包含在构建路径中,为什么它仍然会导致这种错误?
I am trying to compile the example code of "Mahout in Action" in Eclipse. There is a java file titled as "LimitedMemoryDiffStorage.java". Which essentially just define a 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);
}
}
But the eclipse compiler states
The constructor MemoryDiffStorage(DataModel, Weighting, boolean, long) is undefined
I think it is defined in the mahout-core library and has been included in the build path, why it still causes this kind of error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您使用的库版本与书中描述的版本不同。很多时候,某些方法、构造函数甚至类会被更改甚至删除。检查这一点的最佳方法是检查 mahout-core 库的来源,或者至少是字节码。要在 Eclipse 中查看包括构造函数在内的方法,请按 CTRL + SHIFT + T 并输入类名来打开特定的
MemoryDiffStorage
类。然后在大纲视图中您应该看到实际的构造函数及其签名。Maybe you are using a version of the library that is different from the one described in the book. Many times it happens that some of the methods, constructors or even classes are changed or even removed. The best way to check this would be to check the sources of mahout-core library, or at least the byte code. To see the methods including constructor in Eclipse, open the specific
MemoryDiffStorage
class by pressing CTRL + SHIFT + T and typing in the class name. Then in the outline view you should see the actual constructors with their signatures.根据 https://builds.apache.org/job/Mahout-Quality/javadoc/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.html MemoryDiffStorage 构造函数需要三个参数,但您传递了四个参数。
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 are passing it four.