Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class doesn't contain matching constructor for autowiring

I have two classes

public abstract class AbstractDAO<T> {
    private final MyExecutor<T> myExecutor;
    private final Class<T> clazz;

    public AbstractDAO(MyExecutor<T> myExecutor, Class<T> clazz) {
        this.myExecutor = myExecutor;
        this.clazz = clazz;
    }
}

and

@Component
public class MyDAOImpl extends AbstractDAO<Manager> {
    private final SessionManager sessionManager;
    private final MyExecutor<Manager> myExecutor;

    @Autowired
    public MyDAOImpl(SessionManager sessionManager, MyExecutor<Manager> myExecutor) {
        super(myExecutor, Manager.class);

        this.sessionManager = sessionManager;
        this.myExecutor= myExecutor;
    }
}

I got an error at the definition of the abstract class saying that: "Class doesn't contain matching constructor for autowiring".

All I did is added an additional constructor parameter to the constructor of AbstractDAO which is a Class. I need this because I didn't find a way to detect this out from T at run time (stackflow search says there isn't one).

How can I fix this? How can I pass the Class information which can only be determined in the implementation class?

Many thanks

like image 214
Kevin Avatar asked Feb 16 '14 15:02

Kevin


1 Answers

This is a bug in IntelliJ that is fixed in 13.1. http://youtrack.jetbrains.com/issue/IDEA-120977

like image 196
robert_difalco Avatar answered Sep 30 '22 08:09

robert_difalco