So I am playing around with Spring and Java 10 along with Gradle.
In my application, I created 2 modules
- UI
- Application
The application module's gradle file looks like this
dependencies {
compile project (':ui')
}
And module-info file looks like this
module application {
requires spring.context;
requires spring.boot.autoconfigure;
requires spring.boot;
}
In my UI module, the build.gradle looks like this
dependencies {
compile('com.vaadin:vaadin-spring-boot-starter')
}
dependencyManagement {
imports {
mavenBom "com.vaadin:vaadin-bom:${vaadinVersion}"
}
}
And module-info looks like this
module ui {
requires vaadin.server;
requires vaadin.spring;
}
So my UI code lives inside ui module. As you can see, I am not exporting any package outside from the ui module and application's module-info also doesn't require ui.
In the main class I added
@ComponentScan("com.factory_manager")
And magically it's able to scan the UI module and the vaadin UI classes and I am able to access them via their respective endpoints.
From my understanding, the application module should not be able to read ui module's classes as I am not exporting any package outside.
Does anyone has any idea on how spring is magically able to scan the ui module and find the ui classes?
And yes, I am unable to access UI module's classes inside my application module but spring somehow is able to..