Spring-Boot @Autowire constructor short cut


Hi folks,

I'm using intellij with maven to build a spring boot application.
I do very often following:

    private AnyServiceClass anyServiceClass;

    public MyConstructor(AnyServiceClass anyServiceClass) {
        this.anyServiceClass = anyServiceClass;

Is there any short cut to generate the constructor of a private class attribute. Further I would like to add some further attributes, which should be inserted into the constructor automatically. 

Thanks for your help.


评论操作 固定链接

Hi Tim, there should be a quick fix available on alt+enter to add a constructor parameter:

which results in:

It should work with any new field you add. As an option, you can use Cmd+Shift+A / Ctrl+Shift+A and search for an action 'Add constructor parameters'