there is a way to replace constructor-arg with Annotation?
I have this constructor:
public GenericDAOImpl(Class type) {
this.type = type
I think @Inject alone won't help, you will have to use a @Qualifier annotation also.
Here's the relevant Section of the Spring Reference:
3.9.3 Fine-tuning annotation-based autowiring with qualifiers
If I understand this correctly, you will have to use the @Qualifier mechanism.
If you use Spring's @Qualifier annotation, you can probably do it inline, something like this:
@Repository
public class DaoImpl implements Dao{
private final Class> type;
public DaoImpl(@Qualifier("type") final Class> type){
this.type = type;
}
}
But if you use the JSR-330 @Qualifier annotation, I guess you will have to create your own custom annotation that is marked with @Qualifier.
Another possibility would be the @Value annotation. With it you can use Expression Language, e.g. like this:
public DaoImpl(
@Value("#{ systemProperties['dao.type'] }")
final Class> type){
this.type = type;
}