spring
spring copied to clipboard
Add auto scan for "org.vaadin"
A customer of us had the following problem: he added an addon from our directory to his Spring Boot application as maven dependency. After preparing the frontend and starting the application he got a lot of JS errors, which told him in short that the client side stuff of this addon is simply not there.
Adding "org.vaadin" as a package to scan to the @SpringBootApplication
did not help. Rebuilding and restarting the application still showed the same issue.
After adding @EnableVaadin({"com.vaadin", "org.vaadin", ... })
it worked.
To be honest I by myself stumbled over this issue in the past, too and I guess it will happen to others, too, since it is not really clear from the documentation, that @EnableVaadin
has to be used, too, to use addons.
Long text, short request:
Since most addons are in package "org.vaadin" (at least from what I've seen), we should add this package beside "com.vaadin" and the application package to the auto scan for custom components, so that the above mentioned @EnableVaadin
arguments combo is not needed.
I'm not sure if that is technically possible, but I guess it would prevent such issues for most addons out of the box.
Also maybe extending the docs regarding this issue would be a good thing, too :)
Small, but maybe interesting side node: When testing the customer's project on my machine with NodeJS 10.x, it worked with the given SpringBootApplication annotation. The customer with NodeJS 12.x had issues.
Used Spring Boot 2.1.7 and Vaadin 14.1.27.
Does this problem only exist when vaadin.whitelisted-packages
is set? Otherwise the application seems to scan everything for Vaadin annotations anyway, no?
Anyway, I'd prefer a mechanism where every add-on can contribute packages it needs to be scanned. Similar like the spring.factories
file that is used to contribute auto configurations in Spring Boot. That would work for all add-ons, not just the ones that happen to use the org.vaadin
package (mine don't...). Also, and more importantly, this would make manually managing vaadin.whitelisted-packages
obsolete.