Unable to start web server; nested exception is org.springframework.context.ApplicationContextException
时间: 2023-09-23 20:08:06 浏览: 119
Unable to start web server; nested exception is org.springframework.context.ApplicationContextException是由于缺少ServletWebServerFactory bean引起的。这个问题通常是因为在启动类中没有正确配置注解导致的。解决方法是在启动类之前添加@EnableAutoConfiguration注解。同时,确保Controller类已经正确配置了@Controller注解,并且在主程序中使用@SpringBootApplication注解进行配置。下面是一个修正后的示例代码:
```java
@EnableAutoConfiguration
@Controller
public class HelloController {
@ResponseBody
@RequestMapping("/hello")
public String hello(){
return "hello SpringBoot!";
}
}
```
主程序:
```java
@SpringBootApplication
public class HelloApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(HelloController.class, args);
}
}
```
这样,应该就能够解决Unable to start web server的问题了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [SpringBoot报错:Unable to start web ... nested exception is org.springframework.context.Application](https://blog.csdn.net/dl962454/article/details/105881089)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [解决Handler processing failed; nested exception is java.lang.NoClassDefFoundError_kmode exception](https://download.csdn.net/download/lj_70596/14122358)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文