springboot学习系列问题:Tomcat启动报错
eclipse中SpringBoot访问页面报错Description:The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.
问题描述
controller代码片段
package com.bjpowernode.springboot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController {
@RequestMapping("/boot/hello")
public @ResponseBody String hello()
{
return "hello spring boot";
}
}
application代码片段
package com.bjpowernode.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootlearningApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootlearningApplication.class, args);
}
}
运行提示:
浏览器输入localhost:8080/boot/hello显示错误:This application has no explicit mapping for /error…
问题思考
端口被占用;application启动类未放置在最外层
解决方法
查看任务管理器,关掉其他正在运行的eclipse程序