I have a Vaadin 24 LOGIN project that works great. It accesses the database, does all the Spring Security goodness and then goes to the default route ("/").
I have another Vaadin project that has an ADMIN UI that allows the user to perform CRUD commands for managing the users.
I have a third Vaadin project the performs some BUSINESS function.
All the applications are working GREAT by themselves.
I want to be able to use the LOGIN application in both the ADMIN and BUSINESS applications - so I don't have to copy all the same login code into both projects.
In my LOGIN application I've modified the build in the POM so that it will build two jar files - the "fat" executable and the "thin" non-executable:
<!-- UPDATED MAVEN TO CREATE 2 JARS, ONE EXECUTABLE AND ONE "PLAIN" -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build information</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
<execution>
<id>repackage</id>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
I also removed the AppShellConfigurator
from the main class in the LOGIN application.
I then made the LOGIN jar a dependency in the ADMIN application.
The part where I get stuck:
How do I "trigger" the LoginView
that lives in the LOGIN project from the ADMIN application?
Once a successful login has been accepted - will it just redirect to the "/" of whatever main applicatin (e.g. ADMIN or BUSINESS) specifies or ?
Vaadin scans by default all packages below your @SpringBootApplication
for Routes, Components and other configurations.
To let Vaadin find and automatically register your LoginView that resides in another package you have to add the package to the @EnableVaadin
annotation.
Example:
@EnableVaadin(value = {"com.example.login", "com.example.app"})
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
More information can be found in the official documentation.