vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
619 stars 167 forks source link

Starting spring-boot application in IDE takes several minutes #6269

Closed michallichvar closed 5 years ago

michallichvar commented 5 years ago

Description of the bug: Starting my spring-boot project in IDE takes several minutes, because from Vaadin 14, NPM is required and it starts very slowly. With vaadin.compatibilityMode=true it starts within seconds. As compatibilityMode is some temporary solution and won't be in Vaadin 15, I do not want to develop in it even now. I'm not sure whether the logic underhood is the same (between compMode and Vaadin 14)

I have DevTools in pom.

Minimal reproducible example: Any simple spring-boot project with node.js and NPM installed.

Expected behavior: To run within seconds, as with compatibilityMode:

2019-08-19 08:45:42.078  INFO 9924 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-08-19 08:45:42.087  INFO 9924 --- [  restartedMain] s.g.g.frontend.GimsFrontendApplication   : Started GimsFrontendApplication in 4.177 seconds (JVM running for 7.305)

Actual behavior:

2019-08-19 08:24:52.671  INFO 5856 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-08-19 08:24:52.681  INFO 5856 --- [  restartedMain] s.g.g.frontend.GimsFrontendApplication   : Started GimsFrontendApplication in 133.913 seconds (JVM running for 136.849)

Versions:

vaadin-springboot-compatibilitymode.log vaadin-springboot-npm.log

caalador commented 5 years ago

Do you have lots of dependent classes in the project?

2019-08-19 08:22:42.851  INFO 5856 --- [  restartedMain] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2692 ms
2019-08-19 08:24:26.218  INFO 5856 --- [  restartedMain] c.v.f.server.startup.DevModeInitializer  : Starting dev-mode updaters in C:\Users\lichvar\IdeaProjects\gims\gims-frontend folder.

The lines make seem that the ClassScanning is taking the time. We have the ticket https://github.com/vaadin/spring/issues/476 for adding clarity to where time is spent.

For a start you could try adding a WhiteList for packages to scan for the annotations: Route and NpmPackage

Please see documentation for the whitelist parameter https://vaadin.com/docs/v14/flow/spring/tutorial-spring-configuration.html#special-configuration-parameters

vlipovetskii commented 5 years ago

Similar issue https://github.com/vaadin/flow/issues/5803

michallichvar commented 5 years ago

sorry even from #5803 I haven't figured out how to setup white/blacklist property. I tried vaadin.blacklisted-packages=^(java|sun|elemental|javax|org.(apache|atmosphere|jsoup|jboss|w3c|spring|joda|hibernate|glassfish|hsqldb)|com.(helger|spring|gwt|lowagie|google|fasterxml)|net.(sf|bytebuddy)).*

still over minute

caalador commented 5 years ago

Whitelist and blacklist do not use regex so they need to be set as in the documentation. the default blacklist consist of the exlusions:

"antlr", "cglib",
"ch/quos/logback", "commons-codec", "commons-fileupload",
"commons-io", "commons-logging", "com/fasterxml", "com/google",
"com/h2database", "com/helger",
"com/vaadin/external/atmosphere", "com/vaadin/webjar", "javax/",
"junit", "net/bytebuddy", "org/apache", "org/aspectj",
"org/bouncycastle", "org/dom4j", "org/easymock", "org/hamcrest",
"org/hibernate", "org/javassist", "org/jboss", "org/jsoup",
"org/seleniumhq", "org/slf4j", "org/atmosphere",
"org/springframework", "org/webjars/bowergithub", "org/yaml"
michallichvar commented 5 years ago

OK, it's not about whitelist or blacklist, it's about vaadin:build-frontend.

Before start of spring-boot, you should do mvn vaadin:prepare-frontend mvn vaadin:build-frontend (in migration docu, this step is mentioned just for production-mode)

and after that start aplication.

Now start is under 5s.

Even class hotswap works fine.

michallichvar commented 5 years ago

but auto redeploy of css file is now not working :-/

caalador commented 5 years ago

If you run build-frontend the project will not run the webpack dev server. This will make the project start faster as now we do not scan for frontend annotations or start the dev server, but you loose the frontend updates during development.

The time spent comes from when we try to find any frontend data that needs to be added or copied and giving a whitelist of vaadin.whitelisted-packages=com/project/package (in application.properties) would drastically limit the scope that we try to look at for finding Route(s), NpmPackage(s) and WebComponentExporter(s) that will be visited for components.

estronque commented 5 years ago

It seems to be related with https://github.com/vaadin/flow/issues/6404

pleku commented 5 years ago

Not sure what there still left for this issue. Please create a new issue with description on what is broken and when, I'm closing this one.