there is a way to replace constructor-arg with Annotation?
I have this constructor:
public GenericDAOImpl(Class type) {
this.type = type
Spring's Java Configuration might be of help here. If you create a Java class that simply defines your beans using the annotations @Configuration and @Bean it could look something like this:
@Configuration
public class DaoConfiguration {
@Bean
public GenericDAO personDao() {
return new GenericDaoHibernateImpl(Person.class);
}
}
Make sure that the DaoConfiguration class is scanned (typically via @ComponentScan) and a proper DAO-object will be created for you in the Spring context. The bean will have the name of the method which in this case is personDao so you can inject it by name using the name personDao or by type if the type is GenericDAO.