news 2026/5/1 7:13:18

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/5/1 6:44:26

多语言网站本地化:HY-MT1.5实战案例

多语言网站本地化&#xff1a;HY-MT1.5实战案例 随着全球化业务的不断扩展&#xff0c;多语言网站的本地化需求日益增长。传统翻译服务在成本、延迟和定制化方面存在诸多限制&#xff0c;尤其在面对混合语言、专业术语或格式保留等复杂场景时表现不佳。腾讯开源的混元翻译大模…

作者头像 李华
网站建设 2026/4/28 4:59:10

HY-MT1.5-1.8B功耗测试:边缘设备低能耗运行实测报告

HY-MT1.5-1.8B功耗测试&#xff1a;边缘设备低能耗运行实测报告 随着多语言交流需求的快速增长&#xff0c;高质量、低延迟的翻译模型成为智能终端和边缘计算场景的关键技术支撑。腾讯开源的混元翻译大模型HY-MT1.5系列&#xff0c;凭借其在翻译质量、功能扩展与部署灵活性上的…

作者头像 李华
网站建设 2026/5/1 7:10:46

HY-MT1.5-1.8B实战:移动APP实时翻译集成

HY-MT1.5-1.8B实战&#xff1a;移动APP实时翻译集成 随着全球化进程的加速&#xff0c;跨语言交流已成为移动应用不可或缺的功能。然而&#xff0c;传统云端翻译方案存在延迟高、隐私泄露风险和离线不可用等问题&#xff0c;尤其在实时对话、即时消息等场景中表现不佳。为解决…

作者头像 李华
网站建设 2026/5/1 7:10:42

腾讯Youtu-Embedding:20亿参数中文嵌入性能之王

腾讯Youtu-Embedding&#xff1a;20亿参数中文嵌入性能之王 【免费下载链接】Youtu-Embedding 项目地址: https://ai.gitcode.com/tencent_hunyuan/Youtu-Embedding 导语&#xff1a;腾讯优图实验室推出的Youtu-Embedding模型以20亿参数规模&#xff0c;在中文文本嵌入…

作者头像 李华
网站建设 2026/5/1 3:11:54

HY-MT1.5格式化模板库:常见文档类型预设

HY-MT1.5格式化模板库&#xff1a;常见文档类型预设 1. 引言 随着全球化进程的加速&#xff0c;高质量、多语言互译能力已成为企业出海、跨文化交流和智能硬件落地的核心需求。然而&#xff0c;传统翻译模型在面对混合语言、专业术语密集或结构化文本&#xff08;如技术文档、…

作者头像 李华
网站建设 2026/5/1 6:14:18

HY-MT1.5部署遇坑?单卡4090D自动启动避坑指南保姆级教程

HY-MT1.5部署遇坑&#xff1f;单卡4090D自动启动避坑指南保姆级教程 1. 引言&#xff1a;为什么选择HY-MT1.5&#xff1f; 随着多语言交流需求的爆发式增长&#xff0c;高质量、低延迟的翻译模型成为AI应用落地的关键组件。腾讯近期开源的混元翻译大模型1.5版本&#xff08;HY…

作者头像 李华