news 2026/4/18 10:18: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/4/16 20:48:27

STM32在Keil4中的Flash烧录问题解析

深入Keil4烧录现场&#xff1a;STM32 Flash编程失败的根源与实战修复你有没有遇到过这样的场景&#xff1f;代码编译通过&#xff0c;调试器灯亮着&#xff0c;线也插好了——但一点“Download”&#xff0c;Keil弹出一句冷冰冰的提示&#xff1a;“Cortex-M3: No Algorithm Fo…

作者头像 李华
网站建设 2026/4/17 7:31:38

用BART微调医疗病历摘要更稳

&#x1f4dd; 博客主页&#xff1a;jaxzheng的CSDN主页 医疗病历摘要的稳定性革命&#xff1a;BART微调的鲁棒性优化策略目录医疗病历摘要的稳定性革命&#xff1a;BART微调的鲁棒性优化策略 引言&#xff1a;当精度不再是唯一标尺 问题深度剖析&#xff1a;稳定性为何是医疗摘…

作者头像 李华
网站建设 2026/4/17 23:22:27

HY-MT1.5-7B模型推理优化:显存占用降低技巧

HY-MT1.5-7B模型推理优化&#xff1a;显存占用降低技巧 1. 背景与技术挑战 随着大语言模型在多语言翻译任务中的广泛应用&#xff0c;高效部署成为实际落地的关键瓶颈。腾讯开源的混元翻译大模型 HY-MT1.5 系列包含两个核心版本&#xff1a;HY-MT1.5-1.8B 和 HY-MT1.5-7B&…

作者头像 李华
网站建设 2026/4/17 22:45:37

HY-MT1.5-1.8B实时翻译延迟优化实战

HY-MT1.5-1.8B实时翻译延迟优化实战 随着多语言交流需求的不断增长&#xff0c;高质量、低延迟的实时翻译系统成为智能设备、跨语言沟通和全球化服务的核心支撑。腾讯开源的混元翻译大模型HY-MT1.5系列&#xff0c;凭借其在翻译质量与推理效率之间的出色平衡&#xff0c;迅速成…

作者头像 李华
网站建设 2026/4/18 8:28:47

混元翻译1.5模型实战:多语言视频字幕生成

混元翻译1.5模型实战&#xff1a;多语言视频字幕生成 随着全球化内容消费的快速增长&#xff0c;多语言视频字幕的自动生成已成为跨文化传播、在线教育和流媒体平台的核心需求。传统翻译方案在面对复杂语境、混合语言表达以及实时性要求时&#xff0c;往往难以兼顾质量与效率。…

作者头像 李华
网站建设 2026/4/18 5:38:37

PDF-Extract-Kit教程:PDF文档安全处理技巧

PDF-Extract-Kit教程&#xff1a;PDF文档安全处理技巧 1. 引言 1.1 技术背景与学习目标 在数字化办公和学术研究中&#xff0c;PDF 文档已成为信息传递的核心载体。然而&#xff0c;PDF 的封闭性使得内容提取&#xff08;如公式、表格、文本&#xff09;成为一大挑战。传统工…

作者头像 李华