I'm not entirely sure what's the problem, but the sample boot-features from spring-native doesn't work.
It sets
spring.main.web-application-type=none
in application.properties and runs fine in AOT mode. But when running in a native-image, i get this error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Web application could not be started as there was no org.springframework.boot.web.servlet.server.ServletWebServerFactory bean defined in the context.
Action:
Check your application's dependencies for a supported servlet web server.
Check the configured web application type.
org.springframework.boot.web.context.MissingWebServerFactoryBeanException: No qualifying bean of type 'org.springframework.boot.web.servlet.server.ServletWebServerFactory' available: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:211) ~[boot-features:3.0.0-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[boot-features:3.0.0-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[boot-features:3.0.0-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[boot-features:6.0.0-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[boot-features:3.0.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:729) ~[boot-features:3.0.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:428) ~[boot-features:3.0.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[boot-features:3.0.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[boot-features:3.0.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[boot-features:3.0.0-SNAPSHOT]
at com.example.bootfeatures.Application.main(Application.java:15) ~[boot-features:0.0.1-SNAPSHOT]
I get a different error when configuring it explicitly in code with
application.setWebApplicationType(WebApplicationType.NONE);
which looks like it's #31528.
Comment From: wilkinsona
Could it be a missing reflection hint for setWebApplicationType on SpringApplication?
https://github.com/spring-projects/spring-boot/blob/ac59b5781f30d98b8873fd0dc0010a5dbb9ccf5b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java#L536
Without hints, the above won't find any properties to bind so all the spring.main.* properties will be ignored.