If you run it successfully using command line gradle bootRun
, while packaging it with command line gradle jar
to jar file in order to run it with command line java -jar build/libs/demo.jar
, unfortunately, it failed with Exception: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
, in this case, you need to use task bootRepackage
of gradle plugin spring-boot
to generate special runnable jar.
$ gradle clean bootRepackage
$ java -jar build/libs/demo.jar