2017-01-23 33 views
1

私はScalaとJavaの相互運用性を活用しています。また、Javaで書かれた同じプロジェクトでクラスをインスタンス化するためにScalaを使用する以下のコードを用意しています。 CommandExecutorパラメータは、親クラスから継承されます。Scalaがコンストラクタを解決できない

class IdmIdentityServiceImpl extends ServiceImpl with IdmIdentityService { 
    override def createNativeUserQuery: NativeUserQuery = { 
     new NativeUserQueryImpl(commandExecutor) 
     } 
} 

は私がcannot resolve constructor

NativeUserQueryImplはJavaで書かれていたと言うNativeUserQueryImplをインスタンス化して、エラーが発生しますが、私は、JavaとScalaの間の相互運用性について読んで、それが動作するはずのように感じてきました。

これはNativeUserQueryImplクラスです。これは、そのコンストラクタの1つにCommandExecutorタイプを取り入れています。このクラスは、flowable-engineライブラリから来ています。

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); 
    } 

} 

はEDIT:

全エラー

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は、2つの異なるバージョンを持っていることが表示されます図書館

org.flowable.idm.engine.impl.interceptor.CommandExecutorおよび 微妙な違いは、1つはidmパッケージからのものであり、1つはそうでないということです。

ServiceImplを2番目のパッケージから最初のパッケージに変更すると、渡されたCommandExecutorパラメータが更新され、問題が修正されます。

関連する問題