title: Spring bean constructor-arg with generic
body: <p>I'll let my code talk for me, first, here's my root-context.xml:</p>
  
  <pre><code>&lt;context:component-scan base-package="it.trew.prove" /&gt;
  
  &lt;bean id="usersDao" class="it.trew.prove.model.dao.UsersDao" /&gt;
  
  &lt;bean id="usersService" class="it.trew.prove.server.services.UsersServiceImpl" /&gt;
  </code></pre>
  
  <p>Some of my users dao:</p>
  
  <pre><code>public class UsersDao extends ObjectifyDao&lt;User&gt; {
  
      protected UsersDao(Class&lt;User&gt; clazz) {
          super(User.class);
      }
  
      static {
          ObjectifyService.register(User.class);
      }       
  }
  </code></pre>
  
  <p>And my users service (implementation):</p>
  
  <pre><code>public class UsersServiceImpl implements UsersService {
  
      private final UsersDao usersDao;
  
      @Autowired
      public UsersServiceImpl(UsersDao usersDao) {
          this.usersDao = usersDao;
      }
  
      @Override
      public List&lt;User&gt; listUsers() {
          return usersDao.list();
      }
  
      @Override
      public void saveUser(User user) {
          usersDao.add(user);
      }
  }
  </code></pre>
  
  <p>Now my log is:</p>
  
  <blockquote>
    <p>AVVERTENZA: Nested in
    org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'usersController' defined in file
    [/home/fabio/stsworkspace/TestGAE/target/TestGAE-1.0-SNAPSHOT/WEB-INF/classes/it/trew/prove/web/UsersController.class]: Unsatisfied dependency expressed through constructor argument with
    index 0 of type [it.trew.prove.server.services.UsersService]: : Error
    creating bean with name 'usersService' defined in ServletContext
    resource [/WEB-INF/spring/root-context.xml]: Unsatisfied dependency
    expressed through constructor argument with index 0 of type
    [it.trew.prove.model.dao.UsersDao]: : Error creating bean with name
    'usersDao' defined in ServletContext resource
    [/WEB-INF/spring/root-context.xml]: Instantiation of bean failed;
    nested exception is
    org.springframework.beans.BeanInstantiationException: Could not
    instantiate bean class [it.trew.prove.model.dao.UsersDao]: No default
    constructor found; nested exception is
    java.security.PrivilegedActionException:
    java.lang.NoSuchMethodException:
    it.trew.prove.model.dao.UsersDao.(); nested exception is
    org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'usersDao' defined in ServletContext resource
    [/WEB-INF/spring/root-context.xml]: Instantiation of bean failed;
    nested exception is
    org.springframework.beans.BeanInstantiationException: Could not
    instantiate bean class [it.trew.prove.model.dao.UsersDao]: No default
    constructor found; nested exception is
    java.security.PrivilegedActionException:
    java.lang.NoSuchMethodException:
    it.trew.prove.model.dao.UsersDao.(); nested exception is
    org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'usersService' defined in ServletContext
    resource [/WEB-INF/spring/root-context.xml]: Unsatisfied dependency
    expressed through constructor argument with index 0 of type
    [it.trew.prove.model.dao.UsersDao]: : Error creating bean with name
    'usersDao' defined in ServletContext resource
    [/WEB-INF/spring/root-context.xml]: Instantiation of bean failed;
    nested exception is
    org.springframework.beans.BeanInstantiationException: Could not
    instantiate bean class [it.trew.prove.model.dao.UsersDao]: No default
    constructor found; nested exception is
    java.security.PrivilegedActionException:
    java.lang.NoSuchMethodException:
    it.trew.prove.model.dao.UsersDao.(); nested exception is
    org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'usersDao' defined in ServletContext resource
    [/WEB-INF/spring/root-context.xml]: Instantiation of bean failed;
    nested exception is
    org.springframework.beans.BeanInstantiationException: Could not
    instantiate bean class [it.trew.prove.model.dao.UsersDao]: No default
    constructor found; nested exception is
    java.security.PrivilegedActionException:
    java.lang.NoSuchMethodException:
    it.trew.prove.model.dao.UsersDao.():
    java.lang.NoSuchMethodException:
    it.trew.prove.model.dao.UsersDao.()</p>
  </blockquote>
  
  <p>So... in your honest opinion, <strong>how can I change my code to make it work correctly?</strong></p>
  
  <ul>
  <li>Sorry for being so verbose :) -</li>
  </ul>