项目拆包后报错 Consider defining a bean of type
问题
拆包之后,发现项目启动时报错Consider defining a bean of type,这个问题主要是因为项目拆包后,在原有的引用项目中无法找到对应的包的路径。
解决
让原来引用的项目可以找到资源的路径就可以了;或者将启动类 放到一个包拆成两个包后的平行路径中(因为之前只有一个包,启动类是放在包里,拆包后有两个包,想要扫描到两个包,就得将其移到 平行包的路径,很简单,这里不详细说啦)
具体执行步骤
在项目的Application启动文件里,使用@MapperScan注解,把当前的路径引用进去就可以了。
解决方法
(实际用的时候根据自己的包路径进行修改)
1.1@Mapper注解
作用:在接口类上添加了@Mapper,在编译之后会生成相应的接口实现类
添加位置:接口类上面
@Mapper
public interface UserDAO {
//代码
}
如果想要每个接口都要变成实现类,那么需要在每个接口类上加上@Mapper注解,比较麻烦,解决这个问题用@MapperScan
2.1使用@MapperScan单个注解包
MapperScan作用:指定要变成实现类的接口所在的包,然后包下面的所有接口在编译之后都会生成相应的实现类
添加位置:是在Springboot启动类上面添加,添加@MapperScan(“com.peach.mapper”)注解以后,com.peach.mapper包下面的接口类,在编译之后都会生成相应的实现类
@SpringBootApplication
@MapperScan(basePackages = "com.peach.mapper")
public class SystemApplication {public static void main(String[] args {SpringApplication.run(KehuApplication.class, args);
}}
2.2使用@MapperScan注解多个包
@SpringBootApplication
@MapperScan({"org.spring.ext","org.spring.blade"})
public class SystemApplication {public class App {public static void main(String[] args) {SpringApplication.run(App.class, args);}}
注解后再启动就没有报错了,如果有帮助到你,那就太好了!
项目拆包后报错 Consider defining a bean of type相关推荐
- SpringCloud - 整合Nacos启动报错Consider defining a bean of type IClientConfig
SpringCloud - 整合Nacos启动报错Consider defining a bean of type IClientConfig 前言 一. 尝试解决Bug的几种不合适方案 1.1 添加 ...
- 解决启动报错Consider defining a bean of type ‘xxx‘ in your configuration.
解决启动报错Consider defining a bean of type 'xxx' in your configuration. 报错截图 解决方法:查看注解是否同时存在@AllArgsCons ...
- SpringBoot启动报错Consider defining a bean of type ‘com.test.springmvc.dao.xx‘ in your configuration.
报错信息如下: Description:Field userDao in com.test.springmvc.service.impl.UserServiceImpl required a bean ...
- 项目启动报错:No qualifying bean of type ‘xxx‘ available:
项目启动报错: Description: A component required a bean of type 'cn.hsa.its.abutment.bo.BusinessAcceptBo' t ...
- Spring Cloud/Boot启动报错Consider defining a bean of type ServerCodecConfigurer
网关项目启动报错内容如下: Error starting ApplicationContext. To display the conditions report re-run your applic ...
- springboot启动报错: Consider defining a bean of type ‘XXX‘ in your configuration
Consider defining a bean of type 'XXX' in your configuration 出现这个错误,要看看你是否用到了某些组件,但是启动类上没加相应的注解.比如说我 ...
- [SpringBoot报错]Consider defining a bean of type ‘xxx‘ in your configuration, NoSuchBeanDefinitionExce
报错详情: Error starting ApplicationContext. To display the conditions report re-run your application wi ...
- 学习记录报错Consider defining a bean of type ‘org.springframework.web.client.RestTemplate‘ in your configu
springboot启动就报错 信息如下 Field restTemplate in com.atguigu.springcloud.controller.OrderController requir ...
- 【微服务】 网关启动报错 Consider defining a bean of type org.springframework.http.codec.ServerCodecConfigurer
一.现象 微服务启动时报错:Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer ...
最新文章
- linux跨服务器复制文件夹,linux下跨服务器文件文件夹的复制
- 新建linux 服务器初始化配置
- 寻找重复的子树 Find Duplicate Subtrees
- 斑马无线打印服务器,如何设置斑马打印机无线WiFi
- linux route命令的使用详解
- 两台电脑usb直连传数据_如何通过一根USB数据线把手机/平板充当电脑的第二个显示器...
- SAP CRM系统订单模型的设计与实现 1
- dropload 使用表
- 转载——sunlogin远程控制安装bug解决
- Office之下拉字体选项名称为英文
- html5人脸拼图,面向眼机交互的界面控件设计方法研究.pdf
- 未来智安2周年 | 行则将至,未来可期
- 轻量级的肝脏与肝肿瘤 2.5D 分割网络阅读笔记
- android画板需求分析,基于Android的画板的设计与实现论文.doc
- 计算思维(1)-质因数
- 基于ESP8266+433射频控制系统
- 【计算机网络-2】 【第一章】SDU与PDU 笔记
- 【学习记录】多主体中的BDI(Belief-Desire-Intention)
- Dialogue System for Unity文档中文对照版(简雨原创翻译)第一篇(我们开始仙剑demo的剧情)
- Python中[m: ]、[ :n]、[m:n]、[m::n]的含义
热门文章
- 静态ARP绑定设置会导致通过AP连接路由器的包被丢弃
- CB5654开发板之读取云端返回值
- 华为交换机常见NAC操作
- 在北京黑马学习Java01
- 数学建模|准备|经验-优秀论文--工具
- Box2D在VS2010上面的配置
- 2021年中国智慧水利发展环境(PEST)分析:智慧水利建设是实现新阶段水利高质量发展的重要路径[图]
- 虚拟磁带库的数据通信
- 为macbook pro 2013late制作windows 10 u盘系统
- html静态页面作业——汉中印象景点介绍 (19页) HTML+CSS+JavaScript 学生旅行 游玩 主题住宿网页