Springboot - How to Start Embedded Container

SpringBoot - Unable to start embedded container

Annotating with the @SpringBootApplication resolves this issue.

@SpringBootApplication
@RestController
public class SpringBootLoginController {

@RequestMapping("/hello")
String hello() {
return "Hello World!!!";
}

public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootLoginController.class, args);
}
}

Alternatively , by Adding the @EnableAutoConfiguration , @ComponentScan and @Configuration also resolves this issue.

@EnableAutoConfiguration
@RestController
public class SpringBootLoginController {

@RequestMapping("/hello")
String hello() {
return "Hello World!!!";
}

public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootLoginController.class, args);
}
}

Spring framework unable to start embedded container

When using Spring Boot you should not include the other Spring dependencies directly, but rely on Boot's own dependency management. When using the provided "starters" you can be sure that all needed libraries will be included in a matching version.

Instead of including spring-mvc artifact in your pom.xml:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>

use the dedicated Boot starter for webapps, spring-boot-starter-web:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

More details in the the official guide


I believe other parts of your pom.xml are superfluous as well (spring-boot-starter, javax.servlet-api, spring-boot-maven-plugin)

Spring Boot: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

The scheduling guide isn't a web app so you probably have some mouldy stuff in your pom.xml from the REST guide? If you follow the instructions closely it should work. Another potential issue with the code you posted above is that your @EnableAutoConfiguration class is not used in the context, only as a main method (which may not be a problem for the scheduling guide but it probably is for a bunch of others).

Spring boot: Unable to start embedded Tomcat servlet container

Try to change the port number in application.yaml (or application.properties) to something else.



Related Topics



Leave a reply



Submit