news 2026/7/26 17:04:24

Spring Boot问题总结

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Spring Boot问题总结

1.程序包org.springframework.web.bind.annotation不存在

错误描述

执行install命令时报如下错误:

[INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project springboot: Compilation failure: Compilation failure: [ERROR] /E:/Project/Eclipse/NINO/springboot/src/main/java/com/nino/springboot/SpringbootApplication.java:[5,47] 程序包org.springframework.web.bind.annotation不存在 [ERROR] /E:/Project/Eclipse/NINO/springboot/src/main/java/com/nino/springboot/SpringbootApplication.java:[6,47] 程序包org.springframework.web.bind.annotation不存在 [ERROR] /E:/Project/Eclipse/NINO/springboot/src/main/java/com/nino/springboot/SpringbootApplication.java:[9,2] 找不到符号 [ERROR] 符号: 类 RestController [ERROR] /E:/Project/Eclipse/NINO/springboot/src/main/java/com/nino/springboot/SpringbootApplication.java:[12,10] 找不到符号 [ERROR] 符号: 类 RequestMapping [ERROR] 位置: 类 com.nino.springboot.SpringbootApplication [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

我的pom.xml文件

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.nino</groupId> <artifactId>springboot</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>springboot</name> <description>Demo project for Spring Boot</description> <!-- Spring Boot父级依赖,有了它就是个Spring Boot项目了 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.6.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <!-- Spring Boot Maven插件,提供了很多方便的功能 --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
错误分析

参考了下其它正确的Spring Boot项目,发现是这行配置及代码出错了

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency>

把它改成如下代码,重新install成功了

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>

spring-boot-starter和spring-boot-starter-web的区别:

  • spring-boot-starter 是Spring Boot的核心启动器,包含了自动配置、日志和YAML
  • spring-boot-starter-web 支持全栈式Web开发,包括Tomcat和spring-webmvc

Web开发要用后者。

参考

Spring Boot的启动器Starter详解 - chszs的专栏 - CSDN博客
http://blog.csdn.net/chszs/article/details/50610474

2. Unable to start embedded container

问题描述
2015-12-22 09:30:23.582 INFO 3208 --- [ main] controller.UserController : No active profile set, falling back to default profiles: default 2015-12-22 09:30:23.879 INFO 3208 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@12ceb70: startup date [Tue Dec 22 09:30:23 CST 2015]; root of context hierarchy 2015-12-22 09:30:24.391 WARN 3208 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 2015-12-22 09:30:25.211 ERROR 3208 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:764) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:357) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1124) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1113) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at controller.UserController.main(UserController.java:28) [classes/:na] Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:185) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] ... 8 common frames omitted
错误分析

猜测可能是代码编译问题,尝试重新编译,
于是执行Project–>Clean后无果
然后执行:右击项目–>Maven–>Update Project(Alt+F5)解决了。
貌似Maven项目重新编译时使用后者比较好使。

参考

Svn 的 Update 与Maven 的update project 作用有什么区别 - 费曼带我飞 - 博客园
http://www.cnblogs.com/xuyuanjia/p/5706411.html

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/20 19:21:48

32位应用下打印驱动主机的系统学习路径

32位应用在64位系统上打印的幕后英雄&#xff1a;splwow64.exe深度解析你有没有遇到过这种情况&#xff1f;一台老旧的财务软件&#xff0c;运行在全新的Windows 10或Windows 11 x64系统上&#xff0c;点击“打印”按钮后却毫无反应&#xff0c;或者弹出“驱动加载失败”的错误…

作者头像 李华
网站建设 2026/7/21 23:49:28

HY-MT1.5部署成功率提升:网络预加载镜像使用指南

HY-MT1.5部署成功率提升&#xff1a;网络预加载镜像使用指南 随着多语言交流需求的不断增长&#xff0c;高质量、低延迟的翻译模型成为智能应用的核心组件。腾讯开源的混元翻译大模型 HY-MT1.5 系列&#xff0c;凭借其卓越的翻译性能和灵活的部署能力&#xff0c;迅速在开发者…

作者头像 李华
网站建设 2026/7/25 15:12:21

2026年AI翻译新趋势:Hunyuan-HY-MT1.5开源模型+按需计费GPU

2026年AI翻译新趋势&#xff1a;Hunyuan-HY-MT1.5开源模型按需计费GPU 随着多语言交流需求的爆发式增长&#xff0c;AI翻译技术正从“通用可用”向“精准可控、高效部署”演进。2026年&#xff0c;腾讯混元团队推出的 Hunyuan-HY-MT1.5 系列翻译大模型&#xff0c;标志着开源翻…

作者头像 李华
网站建设 2026/7/23 1:41:59

STM32程序卡住?用JLink实时追踪堆栈信息

STM32程序卡住了&#xff1f;别急&#xff0c;用JLink把“死机现场”完整抓出来 你有没有遇到过这种情况&#xff1a;STM32板子烧完程序后&#xff0c;运行一会儿突然不动了——LED不闪、串口没输出、调试器连上却只能看到一堆乱跳的寄存器&#xff1f;这时候你想查 到底是哪…

作者头像 李华
网站建设 2026/7/15 1:19:48

HY-MT1.5实战:构建多语言知识图谱系统

HY-MT1.5实战&#xff1a;构建多语言知识图谱系统 随着全球化信息流动的加速&#xff0c;跨语言理解与内容转换成为智能系统的核心能力之一。在这一背景下&#xff0c;腾讯开源了混元翻译大模型HY-MT1.5系列&#xff0c;包含HY-MT1.5-1.8B和HY-MT1.5-7B两个版本&#xff0c;专…

作者头像 李华
网站建设 2026/7/19 19:11:37

HY-MT1.5-7B学术论文翻译:LaTeX格式保持部署实操

HY-MT1.5-7B学术论文翻译&#xff1a;LaTeX格式保持部署实操 1. 引言 随着大模型在自然语言处理领域的持续突破&#xff0c;高质量、多语言、低延迟的机器翻译需求日益增长。特别是在学术研究场景中&#xff0c;科研人员频繁面临将非母语撰写的论文快速准确地翻译为中文的需求…

作者头像 李华