hilla icon indicating copy to clipboard operation
hilla copied to clipboard

Fusion: Endpoint is not working when defined outside the package of Application.java

Open haijian-vaadin opened this issue 5 years ago • 2 comments
trafficstars

When an Endpoint is defined outside the package of Applicatoin.java, Fusion generates the TypeScript code, but the code doesn't work. The reason being that by default Fusion uses ${project.basedir}/src/main/java for source scanning to generate the ts code. Spring Boot by default uses the package where Application.java is defined for component scanning, thus the Endpoint controller (based on Spring) is not registered.

The best solution would be that everything would just work. The second-best solution would be that we show a warning about the misplaced Endpoint instead of generating not working TS code.

reproducible-project

haijian-vaadin avatar Nov 11 '20 06:11 haijian-vaadin

The best solution would be that everything would just work.

Spring Boot has explicitly chosen to not automatically look for beans outside the package containing the @SpringBootApplication class. This is done to make startup as fast as possible by limiting the places that need to be scanned. We wouldn't be good Spring Boot citizens if we would use a different default in our code.

For that reason, I think a warning would be more appropriate.

Legioth avatar Nov 11 '20 08:11 Legioth

Related: https://github.com/vaadin/spring/blob/master/vaadin-spring/src/main/java/com/vaadin/flow/spring/annotation/EnableVaadin.java#L38

Can't be used in Flow because it's in Spring add-on but this is one more reason to extract the functionality out of flow-server at least and either move it into Spring add-on or make another which depends on Spring add-on.

denis-anisimov avatar Nov 11 '20 08:11 denis-anisimov