title: Spring AOP:Cannot resolve method to a unique method
body: <p>Below is the aspect java code:</p>
  
  <pre><code>public class ParamAspect {
      public void beforeMethodExecution(String name){
           System.out.println("Name: " + name);
      }
      public void beforeMethodExecution(Employee employee){
           System.out.println("Employee Name: " + employee.getName());
      }
  }
  </code></pre>
  
  <p>Below is the context.xml file:</p>
  
  <pre><code>&lt;aop:config&gt;
      &lt;aop:pointcut id="empName" expression="execution(void com.model.Employee.setName(String)) and args(name1)"/&gt;
      &lt;aop:pointcut id="empl" expression="execution(void com.model.Employee.setEmployee(com.model.Employee)) and args(empl)"/&gt;
      &lt;aop:aspect ref="aspect"&gt;
          &lt;aop:before pointcut-ref="empName" method="beforeMethodExecution" arg-names="name1"/&gt;
          &lt;aop:before pointcut-ref="empl" method="beforeMethodExecution" arg-names="empl"/&gt;
      &lt;/aop:aspect&gt;
  &lt;/aop:config&gt;
  </code></pre>
  
  <p>The error I got while executing this is:</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Cannot resolve method 'beforeMethodExecution' to a unique method. Attempted to resolve to overloaded method with the least number of parameters, but there were 2 candidates.
  at org.springframework.beans.BeanUtils.findMethodWithMinimalParameters(BeanUtils.java:290)
  at org.springframework.beans.BeanUtils.findMethodWithMinimalParameters(BeanUtils.java:231)
  at org.springframework.beans.BeanUtils.resolveSignature(BeanUtils.java:332)
  at org.springframework.aop.config.MethodLocatingFactoryBean.setBeanFactory(MethodLocatingFactoryBean.java:72)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
  ... 38 more
  </code></pre>
  
  <p>But again, if I change the method name of the aspect from </p>
  
  <pre><code>`public void beforeMethodExecution(Employee employee){`
  </code></pre>
  
  <p>To</p>
  
  <pre><code>`public void beforeMethodExec(Employee employee){`
  </code></pre>
  
  <p>and change the same in context.xml from</p>
  
  <pre><code>&lt;aop:before pointcut-ref="empl" method="beforeMethodExecution" arg-names="empl"/&gt;
  </code></pre>
  
  <p>To</p>
  
  <pre><code>&lt;aop:before pointcut-ref="empl" method="beforeMethodExec" arg-names="empl"/&gt;
  </code></pre>
  
  <p>Then the code works fine.</p>
  
  <p>Please let me know why the same name method throwing exception.</p>