![](/img/trans.png)
[英]Cannot run Spring Boot 2.0 on Tomcat7: “Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.”
[英]Spring Boot/Tomcat, “Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean”
我知道对此还有其他问题,我已经检查过,但没有一个能解决我的问题。
非常简单的POM ,准备好:将我的应用程序与嵌入式Web服务器一起使用,只需启动即可...
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
很简单的 Boot类:
@SpringBootApplication
@RestController
public class SpringBootApp {
public static void main(String[] args) {
SpringApplication.run(SpringApplication.class, args);
}
@RequestMapping(value = "/")
public String hello() {
return "Hello World from Tomcat";
}
}
尝试过:
ETC ...我不明白为什么它不起作用,尽管我认为Spring Boot很容易。
由于缺少ServletWebServerFactory bean,因此无法启动ServletWebServerApplicationContext。
SpringApplication.run()
第一个参数SpringApplication.run()
是应用程序的主要配置类。 在您的情况下,它是SpringBootApp.class
而不是SpringApplication.class
。 以下将是您的Spring Boot应用程序的正确配置。
public static void main(String[] args)
{
SpringApplication.run(SpringBootApp.class, args);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.