spring boot: 构建项目时报错Not a managed type
今天在学习使用Spring Data JPA的时候,将bean和JpaRepository放在了不同的package中,导致无法构建项目,报以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'readingListRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class bean.Book
异常是逐层抛出的,所以要定位到错误的地方,应该看最底下的内容,
java.lang.IllegalArgumentException: Not a managed type: class bean.Book
也就是我们没有按照SpringBoot的约定,默认扫描(application.java 入口类相对的兄弟包及其子包)
解决方法1:将bean和JpaRepository放在同一个package中。
解决方法2:在JpaRepository上添加注释,使得它能找到bean
@EntityScan("bean.Book")
这里整合以下常见的配置
@ComponentScan(basePackages = "com.boot.demo.xxx.*.*")
用于扫描@Controller @Service@EnableJpaRepositories(basePackages = "com.boot.demo.xxx.*.dao")
用于扫描Dao @Repository@EntityScan("com.boot.demo.xxx.*.*")
用于扫描JPA实体类 @Entity
好吧,现在完全不知道spring-boot的文件结构要如何,多创建了几个包,现在各种找不到类,controller也无法配置,明天继续吧。
spring boot: 构建项目时报错Not a managed type相关推荐
- Jenkins构建项目时报错“message“:“Error processing tar file(exit status 1): write/xxx/no space left on device
文章目录 推荐文章 问题描述 原因分析: 解决方案: 1.查看磁盘占用情况 2.删除没有在用的镜像和容器 3.查找当前目录每个文件夹大小 推荐文章 Jenkins整合SpringCloud+GitLa ...
- spring boot构建基础版web项目(一)springboot、thymeleaf控制层基础构
原文作者:弥诺R 原文地址:http://www.minuor.com/147852147/article 转载声明:转载请注明原文地址,注意版权维护,谢谢! 写前说明 根据个人在各篇博文中看到的信息 ...
- Spring Boot+Vue项目 微博系统(2):构建前端Vue项目
系列目录 Spring Boot+Vue项目 微博系统 目录 系列目录 前言 一.安装Vue CLi 二.构建一个前端项目 三.启动测试 四.项目结构 五.配置 前言 前端项目可以借助 Vue CLi ...
- 使用Angular,Ionic 4和Spring Boot构建移动应用
朋友不允许朋友写用户身份验证. 厌倦了管理自己的用户? 立即尝试Okta的API和Java SDK. 在几分钟之内即可对任何应用程序中的用户进行身份验证,管理和保护. 我是Ionic的忠实粉丝. 几年 ...
- 使用React和Spring Boot构建一个简单的CRUD应用
"我喜欢编写身份验证和授权代码." 〜从来没有Java开发人员. 厌倦了一次又一次地建立相同的登录屏幕? 尝试使用Okta API进行托管身份验证,授权和多因素身份验证. Reac ...
- Spring Boot构建多租户SaaS平台核心技术指南
点击上方蓝色"程序猿DD",选择"设为星标" 回复"资源"获取独家整理的学习资料! 作者 | 树下魅狐 来源 | oschina.net/r ...
- Spring Boot 构建多租户 SaaS 平台核心技术指南
1. 概述 笔者从2014年开始接触SaaS(Software as a Service),即多租户(或多承租)软件应用平台:并一直从事相关领域的架构设计及研发工作.机缘巧合,在笔者本科毕业设计时完成 ...
- 使用Spring Boot构建REST Web服务
本教程提供了有关如何使用Spring Boot构建Restfull Web服务的分步指南. 先决条件: Eclipse IDE(最新版本) Maven的4 Java 1.8 1.创建Maven Web ...
- 如何使用MySQL和JPA使用Spring Boot构建Rest API
Hi Everyone! For the past year, I have been learning JavaScript for full-stack web development. For ...
最新文章
- 怎么查看本地电脑是否安装了Git
- LeetCode--160--相交链表
- Java lamda表达式快速分组
- VSFTPD实战02_需求
- GitHub 添加开源协议
- Python之基础练习题
- PostgreSQL on Linux 最佳部署指南
- .Net程序员学习Linux最简单的方法(转载)
- 了解SQL Server中的GUID数据类型
- oracle 11i 供应商api,Oracle EBS AP 供应商API
- 软考论文案例-论微服务架构及其应用
- ae去闪插件deflicker使用_Ae/Pr视频去闪烁插件REVisionFX DEFlicker v1.7.1 Win大众脸已注册...
- 剪辑神器,分享一个可以批量修改大量视频MD5值的工具
- 表面氨基/羧基/巯基/甲氨基功能化修饰的Fe3O4磁性纳米颗粒
- 中国人民大学与加拿大女王大学金融硕士让你在疫情下的学习有更多的选择
- (四)SGE 常用命令
- Python之路----文件操作
- html5泡泡龙游戏开发随笔
- 使用PL/Scope分析PL/SQL代码
- openstack关闭安全组(网络端口)的限制
热门文章
- 2.25-3.2 周记
- Linux系统调用--getrlimit()与setrlimit()函数详解
- Python全栈工程师(Python3 所有基础内容 0-0)
- 提高Service提高进程优先级别,不被系统容易杀死
- Android开发常用工具类
- drupal常用api
- 来自ChinaUnix的对Linux rc.sysinit, rc, functions脚本的分析和Linux启动分析
- vss6 forgot admin password
- hdu4496并查集的删边操作
- C语言经典例24-分数累加和