SpringBoot搭建多模块项目错误,我是参照这个网址搭建的

然后搭建过程中就遇到了一些bug:https://blog.csdn.net/hanchao5272/article/details/80558780

1、springboot无法启动,都怪这个spring的jar包

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcatat org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at com.fxy.ControllerApplication.main(ControllerApplication.java:13) [classes/:na]
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcatat org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:138) ~[spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:87) ~[spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:554) ~[spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179) ~[spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.15.RELEASE.jar:1.5.15.RELEASE]... 8 common frames omitted

删掉pom.xml中的spring依赖

<dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId><version>5.0.4.RELEASE</version><scope>compile</scope></dependency>

--------------------------------------------------------------------

2、在A模块添加B模块的依赖,记得在A模块的pom.xml中引入B模块的坐标

<dependency><groupId>com.fxy</groupId><artifactId>B</artifactId><version>0.0.1-SNAPSHOT</version><scope>compile</scope></dependency>

例如我的A模块是controller,B模块是service,在controller写好调用方法之后启动,报错

***************************
APPLICATION FAILED TO START
***************************
Description:
Field schedualService in com.fxy.controller.hi required a bean of type 'com.fxy.SchedualService' that could not be found.
Action:
Consider defining a bean of type 'com.fxy.SchedualService' in your configuration.

原因:在service模块没有添加注解@Service

-----------------------------------------------------------------

3、在controller模块注入service模块过程:

先在controller编写

@AutowiredSchedualService schedualService;

此时service类标红,需要Alt + Enter(可能有些人的键位是Alt + /) 提示Add dependency on module service
然后打开controller模块的pom.xml,在最后发现多了一个依赖,即可跨模块调用

<dependency><groupId>com.fxy</groupId><artifactId>service</artifactId><version>0.0.1-SNAPSHOT</version><scope>compile</scope></dependency>

Unable to start embedded container和Consider defining a bean:SpringBoot搭建多模块项目错误相关推荐

  1. 解决springboot启动失败问题:Unable to start embedded container;

    解决springboot启动失败问题:Unable to start embedded container; 参考文章: (1)解决springboot启动失败问题:Unable to start e ...

  2. 报错记录:SprintBoot---Unable to start embedded container; nested exception is java.lang……

    报错信息 练习一个SpringBoot的小例子后,报出以下错误:Unable to start embedded container; nested exception is java.lang.No ...

  3. Nacos在双击startup.cmd启动时提示:Unable to start embedded Tomcat

    场景 Nacos简介.下载与配置持久化到Mysql: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/109356152 在下载Na ...

  4. Nacos 启动报错 Unable to start embedded Tomcat

    问题描述:Nacos官网下载下来的Nacos服务端(nacos-server-2.0.2.zip)在本地(Windows)环境下进行解压后,进入到其bin目录下面,双击"startup.cm ...

  5. Mac系统下运行Java项目出现Unable to start embedded Tomcat server解决方法

    克隆下来代码,运行项目出现如下报错 一直搜索Unable to start embedded Tomcat server这个报错,没有找到方法 下面这个提示也需要看:Caused by: java.n ...

  6. WebServerException: Unable to start embedded Tomcat

    先粘贴一下全部报错信息 [ERROR][2022-07-15 14:49:53 671][main][org.springframework.boot.SpringApplication] : App ...

  7. nacos启动报错 Unable to start embedded Tomcat 以及项目链接nacos报错 server is DOWN now, please try again later!

    一 Unable to start embedded Tomca nacos启动报错如下,原因是没有以单机模式启动. 解决方式 修改nacos启动文件 startup.cmd中下列参数. set MO ...

  8. SpringBoot 嵌入式Tomcat无法启动:Unable to start embedded Tomcat

    问题: Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomc ...

  9. 关于解决搭建Eureka出现的Unable to start embedded Tomcat;无法启动嵌入式tomcat异常

    今天在搭建Eureka的时候,死活都跑不起来!一直提示 Unable to start web server; nested exception is org.springframework.boot ...

最新文章

  1. bitcoin cash的地址格式 cash addr 简介
  2. accept系统调用内核实现
  3. php pdo预处理查询,关于php:从PDO预处理语句中获取原始SQL查询字符串
  4. 双色球霸主网络问题_霸主–统治和管理API的地方
  5. oracle+tquery,Oracle测试题及答案
  6. 使用 Spring 进行单元测试
  7. Flutter基础布局组件及实现
  8. PHP在线支付类集锦(银联支付宝手机支付宝微信等)
  9. eNSP 华为模拟器更新说明
  10. html木马制作教程,利用Internet Explorer Object Data漏洞制做全新网页木马
  11. 几张清晰的图讲清楚什么是Java堆碎片?(内存碎片化)
  12. 动态ip和静态ip的区别
  13. 微信小程序授权登录、绑定手机号(接口+小程序)
  14. EEG多元模式分析预测慈善捐赠行为
  15. 应用软件设计不是CRUD:如何进行应用系统功能模块的耦合性设计
  16. python的turtle的正六角形简洁画法
  17. 【Spark Streaming】(四)基于 Spark Structured Streaming 的开发与数据处理
  18. Java并发编程之volatile
  19. 如何进行特征工程,以及特征工程的一些理论
  20. draftsight linux 32,DraftSight停止提供Linux版:所有免费版将于2019年12月31日后停止运行...

热门文章

  1. 免费的设备管理app
  2. vue3 antd项目实战——Modal弹窗自定义遮罩 (利用maskStyle属性自定义遮罩样式)
  3. 听说高度近视的人不能打拳击?其实真相是这样的......
  4. Uubuntu16.04安装华硕ASUS Xtion驱动并简单使用
  5. c语言xdata作用,请问一下关键字data是什么意思,是关于C语言的问题!
  6. 转:2018全美最佳CEO谈“领导力”
  7. 能站在第一线丑点老点没关系
  8. puppeteer 设置cookie
  9. 10行python代码的词云
  10. linux vim 查找或替换空格