2017-01-23 141 views
1

我利用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) 
+0

commandExecutor定义在哪里? – nmat

+0

@nmat在同一个项目中 – Rafa

+0

它从父类继承。我添加了包含在其中的完整类签名。它位于'ServiceImpl' – Rafa

回答

0

从张贴在原来的问题完整的错误,看来是从ServiceImpl父类继承的CommandExecutor有两个不同的版本图书馆

org.flowable.idm.engine.impl.interceptor.CommandExecutororg.flowable.engine.impl.interceptor.CommandExecutor其中细微的区别在于一个来自idm包,而另一个不是。

将ServiceImpl从第二个包更改为第一个,更新正在传入的参数CommandExecutor并修复了问题。

相关问题