title: Spring - Autowire java.lang.NoClassDefFoundError
body: <p>I'm very new to Spring and Java on the web in the general but I've been struggling with this over the weekend. Getting all the configuration together and to get Spring working with gradle on IntelliJ itself was a challenge. </p>
  
  <p>I'm trying to implement another one of my projects in Spring so that I may better understand how to work with it.</p>
  
  <p>I've been getting this error all morning and I've gone through many references and guides on Spring but am unable to see what the problem is.</p>
  
  <blockquote>
    <p>Caused by: org.springframework.beans.factory.BeanCreationException:
    Could not autowire field: private demo.models.company.CompanyService
    demo.models.company.CompanyController.companyService; nested
    exception is org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'companyServiceImpl' defined in URL
    [jar:file:/Users/user/Documents/Project/demo/build/libs/demo-0.1.0.jar!/demo/models/company/CompanyServiceImpl.class]:
    Initialization of bean failed; nested exception is
    java.lang.NoClassDefFoundError:
    org/aspectj/util/PartialOrder$PartialComparable</p>
  </blockquote>
  
  <p>My service - </p>
  
  <pre><code>public interface CompanyService {
      public Company create(Company company);
      public Company delete(Long id) throws CompanyNotFoundException;
      public List&lt;Company&gt; findAll();
      public Company update(Company company) throws CompanyNotFoundException;
      public Company findById(Long id);
  
  }
  </code></pre>
  
  <p>My implementation -</p>
  
  <pre><code>import org.springframework.stereotype.Service;
  import org.springframework.transaction.annotation.Transactional;
  import demo.exceptions.CompanyNotFoundException;
  
  import javax.annotation.Resource;
  import java.util.List;
  
  
  @Service
  public class CompanyServiceImpl implements CompanyService {
  
      @Resource
      private CompanyRepository companyRepository;
  
      .....
  
  }
  </code></pre>
  
  <p>My controller - </p>
  
  <pre><code>import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  import java.util.List;
  
  @Controller
  @RequestMapping(value="/company")
  public class CompanyController {
  
      @Autowired
      private CompanyService companyService;
  
  
      @RequestMapping("/list")
      public @ResponseBody
      List&lt;Company&gt; company(
              ) {
  
          return companyService.findAll();
      }
  }
  </code></pre>
  
  <p>I've been following the guides on Spring.io on building RESTful services as well as a few articles on JavaCodeGeeks (especially - <a href="http://www.javacodegeeks.com/2013/05/spring-jpa-data-hibernate-mysql-maven.html" rel="noreferrer">http://www.javacodegeeks.com/2013/05/spring-jpa-data-hibernate-mysql-maven.html</a>).</p>
  
  <p>Any help would be greatly appreciated.</p>