Spring Boot + JPA 多模块项目无法注入 JpaRepository 接口
问题描述
Spring Boot + JPA 多模块项目,启动报异常:
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type '***.***.***Dao' available:
expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
解决方案
在启动类添加 @ComponentScan, @EnableJpaRepositories, @EntityScan 注解:
@SpringBootApplication
@ComponentScan("***.***") // 1. 多模块项目需要扫描的包
@EnableJpaRepositories("***.***.***") // 2. Dao 层所在的包
@EntityScan("***.***.***") // 3. Entity 所在的包
参考:SpringBoot JPA 中无法注入 JpaRepository 接口@ComponentScan无效
本人 C# 转 Java 的 newbie, 如有错误或不足欢迎指正,谢谢
Spring Boot + JPA 多模块项目无法注入 JpaRepository 接口的更多相关文章
- Spring Boot + MyBatis 多模块项目搭建教程
一.前言 1.开发工具及系统环境 IDE:IntelliJ IDEA 2020.2.2 系统环境:Windows 2.项目目录结构 biz层:业务逻辑层 dao层:数据持久层 web层:请求处理层 二 ...
- spring boot:构建多模块项目(spring boot 2.3.1)
一,为什么要使用多模块? 1,结构更清晰,方便管理 如果只是一个小项目当然没有问题, 但如果功能越增越多则管理越来越复杂, 多模块可以使项目中模块间的结构分离 2,把项目划分成多 ...
- Spring Boot JPA 连接数据库
本文将介绍怎样在Spring Boot project中加入JPA作为持久化方式. 改动 pom.xml 依赖 与上一篇介绍的 jdbc 不同的是 spring-boot-starter-jdbc 改 ...
- Github点赞超多的Spring Boot学习教程+实战项目推荐!
Github点赞接近 100k 的Spring Boot学习教程+实战项目推荐! 很明显的一个现象,除了一些老项目,现在 Java 后端项目基本都是基于 Spring Boot 进行开发,毕竟它这 ...
- Spring Boot(五):Spring Boot Jpa 的使用
在上篇文章Spring Boot(二):Web 综合开发中简单介绍了一下 Spring Boot Jpa 的基础性使用,这篇文章将更加全面的介绍 Spring Boot Jpa 常见用法以及注意事项. ...
- Spring Boot + JPA(hibernate 5) 开发时,数据库表名大小写问题
(转载)Spring Boot + JPA(hibernate 5) 开发时,数据库表名大小写问题 这几天在用spring boot开发项目, 在开发的过程中遇到一个问题hibernate在执 ...
- Spring Boot Jpa 的使用
Spring Boot Jpa 介绍 首先了解 Jpa 是什么? Jpa (Java Persistence API) 是 Sun 官方提出的 Java 持久化规范.它为 Java 开发人员提供了一种 ...
- (转)Spring Boot(五):Spring Boot Jpa 的使用
http://www.ityouknow.com/springboot/2016/08/20/spring-boot-jpa.html 在上篇文章Spring Boot(二):Web 综合开发中简单介 ...
- Spring Boot(十五):spring boot+jpa+thymeleaf增删改查示例
Spring Boot(十五):spring boot+jpa+thymeleaf增删改查示例 一.快速上手 1,配置文件 (1)pom包配置 pom包里面添加jpa和thymeleaf的相关包引用 ...
随机推荐
- PAT Saving James Bond - Easy Version
Saving James Bond - Easy Version This time let us consider the situation in the movie "Live and ...
- SQLServer连接cache数据库
开始文章之前首先要了解一下什么是Caché数据库. Caché数据库是美国Intersystems公司产品,后关系型数据库(Post Relational database)中的领头羊.Caché数据 ...
- 2020提高组模拟赛7 StormWind
StormWind 中文 切换语言(Change Language) 时间:4s 空间:512M 题目描述: 风暴城建造的防线错综复杂,可以抽象成一个有$n$个点$m$条边的有向拓扑图,暴风城的最 ...
- php xml转数组
<?php libxml_disable_entity_loader(true); $notify_values = json_decode(json_encode(simplexml_load ...
- Firefox威武 尚译威武!
有感于鹰文文档看起来麻烦,期待有一款即时翻译的工具,在windows上还可以,但是上班用的是ubuntu,所以就想到要找一个firefox插件,还真找到了,但是不是插件,是一个书签,那就是尚译!尚哥威 ...
- waeshall算法原理和实现
传递闭包Warshall方法简要介绍 ① 在集合X上的二元关系R的传递闭包是包含R的X上的最小的传递关系.R的传递闭包在数字图像处理的图像和视觉基础.图的连通性描述等方面都是基本概念.一般用B表示定义 ...
- ssh连接客户端一段时间没响应就断掉的解决办法-保持长连接
修改(添加)server端的 /etc/ssh/sshd_config #server每隔60秒发送一次请求给client,然后client响应,从而保持连接 ClientAliveInterval ...
- nice-ni 耗光cpu
可以看到 低优先级的进程 暂用了比较高的CPU时间. top 命令中可以看到 NI 为19, 其优先级最低 但是使用cpu 最高. 说明这个进程需要经行优化了, 通过gdb 发现此进程一直都在处理报文 ...
- 主动关闭 time-wait 2msl 处理
先上传后面整理 /* * This routine is called by the ICMP module when it gets some * sort of error condition. ...
- samba配置用户访问方法
配置目的: 为了给指定用户一个独立访问目录 首先在samba服务器安装samba软件 $ apt-get install samba 然后配置独立访问用户 配置samba用户前提需要是linux的用户 ...