I am totally new to Spring and started to do the official guides from this site: https://spring.io/guides
I\'d like to do this guide: https://spring.io/guides/gs/sch
Add
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
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
if you experience this exception while using intellij and you are trying to start the application with the run
button. Try starting the application from the command line instead. E.g. ensure that you are in the correct directory (directory with your pom file) assuming this is a springboot
application run mvn spring-boot:run
this did the trick for me.
Additionally I have also seen this error occur when your spring application depends on another application. In this case I had to start the other application first then run.
I have stuck with same problem. As I didn't define Main.class and the following annotations in Spring-Boot using Maven:
@SpringBootApplication
public class Main {
public static void main(String args[]){
SpringApplication.run(Main.class, args);
}
}
I am using gradle, met seem issue when I have a commandLineRunner consumes kafka topics and a health check endpoint for receiving incoming hooks. I spent 12 hours to figure out, finally found that I used mybatis-spring-boot-starter with spring-boot-starter-web, and they have some conflicts. Latter I directly introduced mybatis-spring, mybatis and spring-jdbc rather than the mybatis-spring-boot-starter, and the program worked well.
hope this helps
I had this Exception in the following situation.
in my POM was properties:
<properties>
<java.version>1.8</java.version>
<!-- The main class to start by executing java -jar -->
<start-class>com.scmaer.java.microservice.Application</start-class>
<cxf.version>3.1.5</cxf.version>
<olingo.version>2.0.10</olingo.version>
<spring.boot.version>1.4.7.RELEASE</spring.boot.version>
<spring.boot.plugin.version>1.5.8.RELEASE</spring.boot.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>false</skipTests>
</properties>
and the name and path of my application class ("start-class") was wrong.