我利用Scala和Java之间的互操作性,并使用Scala的下面的代码,在用Java编写的同一个项目中实例化一个类。 CommandExecutor
参数是从父类继承的。Scala无法解析构造函数
class IdmIdentityServiceImpl extends ServiceImpl with IdmIdentityService {
override def createNativeUserQuery: NativeUserQuery = {
new NativeUserQueryImpl(commandExecutor)
}
}
我得到一个错误,在实例NativeUserQueryImpl
,说cannot resolve constructor
NativeUserQueryImpl
是用Java编写的,但我一直在阅读有关Java和Scala之间的互操作性,感觉像它应该工作。
这是NativeUserQueryImpl
类,它在其构造函数之一中包含CommandExecutor
类型。该类来自流动引擎库。
public class NativeUserQueryImpl extends AbstractNativeQuery<NativeUserQuery, User> implements NativeUserQuery {
private static final long serialVersionUID = 1L;
public NativeUserQueryImpl(CommandContext commandContext) {
super(commandContext);
}
public NativeUserQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}
// results ////////////////////////////////////////////////////////////////
public List<User> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
return commandContext.getUserEntityManager().findUsersByNativeQuery(parameterMap, firstResult, maxResults);
}
public long executeCount(CommandContext commandContext, Map<String, Object> parameterMap) {
return commandContext.getUserEntityManager().findUserCountByNativeQuery(parameterMap);
}
}
编辑:
完整的错误
Error:(31, 5) overloaded method constructor NativeUserQueryImpl with alternatives:
(x$1: org.flowable.idm.engine.impl.interceptor.CommandExecutor)org.flowable.idm.engine.impl.NativeUserQueryImpl <and>
(x$1: org.flowable.idm.engine.impl.interceptor.CommandContext)org.flowable.idm.engine.impl.NativeUserQueryImpl
cannot be applied to (org.flowable.engine.impl.interceptor.CommandExecutor)
new NativeUserQueryImpl(commandExecutor)
commandExecutor定义在哪里? – nmat
@nmat在同一个项目中 – Rafa
它从父类继承。我添加了包含在其中的完整类签名。它位于'ServiceImpl' – Rafa