news 2026/6/10 11:04:33

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/6/10 15:50:19

多语言网站集成HY-MT1.5:实时翻译插件开发指南

多语言网站集成HY-MT1.5&#xff1a;实时翻译插件开发指南 随着全球化进程加速&#xff0c;多语言网站已成为企业拓展国际市场的重要工具。然而&#xff0c;传统翻译服务往往依赖云端API&#xff0c;存在延迟高、成本大、隐私泄露等风险。腾讯开源的混元翻译模型 HY-MT1.5 为这…

作者头像 李华
网站建设 2026/6/10 17:07:33

HY-MT1.5-1.8B量化实战:FP16与INT8对比测试

HY-MT1.5-1.8B量化实战&#xff1a;FP16与INT8对比测试 随着大模型在翻译任务中的广泛应用&#xff0c;如何在保证翻译质量的同时降低推理成本、提升部署效率&#xff0c;成为工程落地的关键挑战。腾讯开源的混元翻译模型HY-MT1.5系列&#xff0c;凭借其在多语言互译、边缘部署…

作者头像 李华
网站建设 2026/6/10 15:59:14

腾讯开源翻译模型实战:HY-MT1.5上下文翻译应用

腾讯开源翻译模型实战&#xff1a;HY-MT1.5上下文翻译应用 1. 引言 随着全球化进程的加速&#xff0c;跨语言沟通已成为企业出海、内容本地化和国际协作的核心需求。然而&#xff0c;传统翻译模型在面对混合语言输入、专业术语一致性以及上下文连贯性等复杂场景时&#xff0c;…

作者头像 李华
网站建设 2026/6/9 23:41:21

腾讯HY-MT1.5翻译大模型:多语言FAQ系统构建

腾讯HY-MT1.5翻译大模型&#xff1a;多语言FAQ系统构建 1. 引言&#xff1a;从通用翻译到场景化智能翻译的演进 随着全球化进程加速&#xff0c;跨语言信息交互需求激增。传统机器翻译系统在面对专业术语、混合语种对话和上下文依赖等复杂场景时&#xff0c;往往表现乏力。腾…

作者头像 李华
网站建设 2026/6/10 16:35:35

从零实现GRBL移植:STM32开发实战案例

从零实现GRBL移植&#xff1a;STM32开发实战技术深度解析当CNC遇上ARM&#xff1a;为什么我们不再满足于AVR&#xff1f;你有没有遇到过这样的场景&#xff1f;一台基于Arduino的3D打印机在高速打印复杂模型时突然抖动&#xff0c;轨迹偏移&#xff1b;或者一台老式雕刻机执行长…

作者头像 李华
网站建设 2026/6/9 20:52:18

腾讯混元翻译模型HY-MT1.5:从入门到高阶部署完整指南

腾讯混元翻译模型HY-MT1.5&#xff1a;从入门到高阶部署完整指南 1. 引言 随着全球化进程的加速&#xff0c;跨语言沟通已成为企业出海、内容本地化和国际协作的核心需求。然而&#xff0c;传统翻译服务在准确性、响应速度和多语言支持方面仍面临诸多挑战。在此背景下&#xf…

作者头像 李华