記錄一個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>