A simple tool to use a Tray Launcher for Spring Boot Applications
- Add the tray launcher dependency to maven ..
<dependencies>
<dependency>
<groupId>org.fuchss</groupId>
<artifactId>tray-launcher-4-spring-boot</artifactId>
<version>X.Y.Z</version>
</dependency>
</dependencies>
- Create a simple configuration that contains at least the name, default url, and icon of your project:
SpringBootTrayLauncherConfiguration conf = new SpringBootTrayLauncherConfiguration(
"Name",
"http://localhost:8080",
Main.class.getResourceAsStream("/icon.jpg")
);
- Modify your main class:
@SpringBootApplication
@EnableAutoConfiguration
public class Main {
public static void main(final String[] args) {
// Replace SpringApplication.run(Main.class, args) by this ..
SpringBootTrayLauncherConfiguration conf = new SpringBootTrayLauncherConfiguration("Name", "http://localhost:8080", Main.class.getResourceAsStream("/icon.jpg"));
// You may add additional Urls for the launcher
conf.setAdditionalUrls(List.of(new URLEntry("Login", "http://localhost:8080/login")));
SpringBootTrayLauncher.run(Main.class, args, conf);
}
}
- Now you can start your application and use a simple tray icon :)