Spring Boot use SystemTray Icons

The Solution is, rather than using SpringApplication.run(MyConfig.class,args), use the following setup:

    SpringApplicationBuilder builder = new SpringApplicationBuilder(MyConfig.class);
    builder.headless(false);
    ConfigurableApplicationContext context = builder.run(args);

To actually add the System Icon I then added a bean of the followign type:

public class MyTrayIcon extends TrayIcon {

    private static final String IMAGE_PATH = "/path/icon_16x16.png";
    private static final String TOOLTIP = "Text";

    private PopupMenu popup;
    private SystemTray tray;

    public MyTrayIcon(){
        super(createImage(IMAGE_PATH,TOOLTIP),TOOLTIP);
        popup = new PopupMenu();
        tray = SystemTray.getSystemTray();
    }

    @PostConstruct
    private void setup() throws AWTException{
        // popup.add(itemAbout);
        // here add the items to your popup menu. These extend MenuItem
        // popup.addSeparator();
        setPopupMenu(popup);
        tray.add(this);
    }

    protected static Image createImage(String path, String description){
        URL imageURL = MyTrayIcon.class.getResource(path);
        if(imageURL == null){
            System.err.println("Failed Creating Image. Resource not found: "+path);
            return null;
        }else {
            return new ImageIcon(imageURL,description).getImage();
        }
    }
}