简体   繁体   中英

Spring boot forcing headless mode

I am trying to build a simple maven based app for automated testing using SikuliX. The app is currently created as a most recent spring-boot application (v. 1.4.1). The app itself is rather simple (POC at the moment), one class as an Application (SpringBootApplication annotated, implementing CommandLineRunner) and one service (autowired, impl and interface). Nothing more, no other dependencies (just SikuliX, commons-lang3 and spring-boot-starter).

However, when I do run the app, Sikuli subsystem complaints about being run in headless mode.

I have tried using SpringApplicationBuilder.headless(false).web(false).run(args); setting System.setProperty("java.awt.headless", "false"); passing arguments to the JVM to disable headless mode. None of the options alone works as well as their combination. Spring-boot always assumes headless mode.

Is there anybody who come across issue like this?

PS: os is mac and windows, java 1.8

Have a nice day folks.

J.

Sikuli cannot be run in a headless mode. This is a known limitation. The reason for that is the Java Robot library that is being used internally by Sikuli. In other words, you must have a running machine with a screen to make Sikuli work.

I was having the same issue and fixed it by setting the java.awt.headless system property to false. This is the suggestion from M. Deinum in a comment to the OP so credit to them.

Here is how I added it to my main application file:

public static void main(String[] args) {
    System.setProperty("java.awt.headless", "false"); //ADD THIS
    SpringApplication.run(MyClass.class, args);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM