Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Services Bean can not autowired in some classes

Marco Hacegaba
4 years ago Aug 07, 2018 12:28am
Jean-Christophe Gueriaud
4 years ago Aug 07, 2018 8:00am
Marco Hacegaba
4 years ago Aug 07, 2018 4:25pm
Jean-Christophe Gueriaud
4 years ago Aug 08, 2018 12:33pm

For MainView (I don't know if ou have the same problem in ResidentView), you cannot use @autowired bean in your constructor (it's not yet autowired).

You can use final on your autowired bean:

@Autowired private final ResidentialService residentialService;

And add this as an argument of your constructor (or you can use it on a @PostConstruct method)

Here an explanation: https://www.petrikainulainen.net/software-development/design/why-i-changed-my-mind-about-field-injection/