Spring Boot 2.0 新人会踩的坑--启动报404错误
2021-05-08 15:03
204 查看
转载自:http://www.javaman.cn/channels/sb2
启动程序,验证效果
根据图示,点击按钮,来启动 Spring Boot Web 程序, 查看控制台输出:
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.4.RELEASE) 2019-04-14 19:57:59.795 INFO 3680 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on 192.168.0.100 with PID 3680 (/Users/a123123/Work/IdeaProjects/demo/target/classes started by allen-jiang in /Users/a123123/Work/IdeaProjects/demo) 2019-04-14 19:57:59.798 INFO 3680 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2019-04-14 19:58:00.666 INFO 3680 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2019-04-14 19:58:00.689 INFO 3680 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2019-04-14 19:58:00.689 INFO 3680 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17] 2019-04-14 19:58:00.756 INFO 3680 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-04-14 19:58:00.757 INFO 3680 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 920 ms 2019-04-14 19:58:00.978 INFO 3680 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2019-04-14 19:58:01.183 INFO 3680 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2019-04-14 19:58:01.186 INFO 3680 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 1.678 seconds (JVM running for 2.176) 当控制台日志中输出了 Tomcat started on port(s): 8888 (http) with context path ''时,表示内嵌的 Tomcat 容器已经启动成功了,端口为 8080 !
接下来,我们在浏览器上访问 http://localhost:8888/hello 接口,验证一下,接口是否能够正常访问:
返回了我们想要的 Hello, Spring Boot ! 字符串,接口访问正常,大工告成!
SpringbootApplication.png
注意!!!: @SpringBootApplication注解的类必须要放在包扫描的最外层才可以。
否则页面会报404错误。
四、总结
本文中,我们首先了解了什么是 Spring Boot, 以及Spring Boot 的相关特性,最后我们手把手学习了如何搭建一个 Spring Boot 项目,并编写了第一个接口且访问成功。
通过实际操作,真切地感受到了 Spring Boot 的魅力所在!老铁,双击 666!
相关文章推荐
- Springboot启动的时候,url都什么都是对的,但是访问出现404错误
- springboot2.0 war在tomcat下启动一直404
- SpringBoot 2.0 启动报Description: Failed to auto-configure a DataSource的错误
- 使用Spring Boot操作Hive JDBC时,启动时报出错误:NoSuchMethodError: org.eclipse.jetty.servlet.ServletMapping.setDef
- springBoot启动错误:Field categoryMapper in xxx.xxx.service.impl.CategoryServiceImpl required a bean of
- spring boot无法启动,或者正常启动之后无法访问报404的解决办法
- springboot 启动错误= 2
- springboot2.0 war 配置并放入tomcat启动成功
- Spring Boot+Shiro+Redis(redisson)整合时,采用内嵌tomcat启动错误原因分析
- Spring boot 启动jsp访问404问题解决
- Springboot项目打成war包,部署到tomcat上,正常启动访问报错404
- SpringBoot项目运行之后出现网页404错误
- springboot使用之四:错误页面404处理建议
- 解决spring boot中rest接口404,500等错误返回统一的json格式
- springboot启动正常,访问restController报404
- 记一次Springboot 启动错误(二)
- spring boot 正常启动,访问控制时报404
- 新建的SpringBoot项目启动报 “Exception in thread "main" java.lang.IllegalArgumentException”错误解决办法
- spring-boot初学者:记一次搭建web项目404的错误排查过程
- Spring Boot+Shiro+Redis(redisson)整合时,采用内嵌tomcat启动错误原因分析