记录一个Springboot启动的问题->sprinboot正常启动但是tomcat却没有启动

记录一个Springboot启动的问题->sprinboot正常启动但是tomcat却没有启动

  • 启动类如下

    @RestController
    @SpringBootApplication
    public class DemoDeployApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(DemoDeployApplication.class, args);
        }
    
        @RequestMapping("hello")
        public String hello() {
            return "hello";
        }
    
    }
    
  • 启动日志如下

    2020-03-24 14:36:52.906  INFO 96874 --- [           main] demo.DemoDeployApplication               : Starting DemoDeployApplication on yangdeMacBook with PID 96874 (/Users/yang/IdeaProjects/demo/demo-deploy/target/classes started by yang in /Users/yang/IdeaProjects/demo)
    2020-03-24 14:36:52.908  INFO 96874 --- [           main] demo.DemoDeployApplication               : The following profiles are active: local
    2020-03-24 14:36:53.370  INFO 96874 --- [           main] demo.DemoDeployApplication               : Started DemoDeployApplication in 0.903 seconds (JVM running for 1.552)
    
    Process finished with exit code 0
    
  • 从日志启动日志看来,springboot内置的tomcat并没有被启动,端口也没有监听。

  • 经过排查,终于找到了。。。

    pom依赖中,我的依赖是这样的:

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>5.2.4.RELEASE</version>
    </dependency>
    

    看了别的可以启动的项目,改成了springboot的web依赖,终于好了。。。

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    
posted @ 2020-03-24 17:26  一把水果刀  阅读(4289)  评论(0编辑  收藏  举报