Home > OS >  Function expects two parameters, but definition only contains one parameter
Function expects two parameters, but definition only contains one parameter

Time:03-02

I'm having a very odd issue, and it's very simple but I don't understand what the problem is.

I have one class, ClassA that calls a function in ClassB such as ->

ClassA {
  
  private transient MessageHelper MessageHelper
  private transient ClassB classB;

  private boolean messageNotification(Param1 firstParam, Param2 secondParam)
  {
    ...messageBean = messageHelper.getAMessageBean(firstParam, secondParam)...
    
    ...

    classB.sendMessage(messageBean);
  }
}

Class A is a bean defined in my applicationContext.xml like >>

    <bean id="classa" >
        <property name="messageHelper" ref="messageHelper"/>
        <property name="classB" ref="classB"/>
    </bean>

the function definition in ClassB looks like >>

public boolean sendMessage(MessageBean bean) throws MessageException { ... }

IntelliJ doesn't point out any syntax issues, and everything looks normal... However, when trying to compile I get an exception from Maven >>

ClassA.java:[292,27] method sendMessage in class MessageSender cannot be applied to given types;
  required: MessageBean,boolean
  found: MessageBean
  reason: actual and formal argument lists differ in length

Class B is in a different module than Class A, so class B is in ClassA's pom.xml as a dependency

I'm using jdk 1.8.0_212 and maven version 3.6.3

ClassB's module builds with no issues at all. error occurs while running mvn clean install in ClassA's module I've tried invalidating cache' in intellij

Can someone please help me understand what the issue here is?

CodePudding user response:

Your Maven finds some old version of module that contains classB already compiled so it doesn't rebuild that module. Try to clear in your inteliJ your target directory and also see if you have that module present in your m2 local repository. If it is there delete it. It will force the classB module to be rebuilt as you build your classA module. Also you may want to run the build for classB module manually if you can.

CodePudding user response:

Try mvn install on the module that contains ClassB

Note: Added this answer as I cannot add comment as a new contributor.

  • Related