spring data jpa 出现Not a managed type
来源:互联网 发布:java将xml转换成json 编辑:程序博客网 时间:2024/06/07 02:37
主要就是实体没注入进去,或者什么没注入进入,这个具体要看日志提示信息.
spring data jpa 由于我用的是spring boot,所以我只说spring boot中的解决。需要在配置类的上面加上@EnableJpaRepositories(basePackages={"dao层对应的包路径"}),这样jpa的dao层就注入进来了。结果启动spring boot 时发现,又有 Not a managed type: class ******的错误,经查询发现少了jpa entity路径的配置,在配置类的头部加上标记:@EntityScan("entity对应的包路径")。对于spring boot 使用jpa,需要在目录下加上application.properties文件,如果是maven项目在resource目录下,里面是jpa的一些数据的配置例如:
spring.datasource.url=jdbc:mysql://192.168.1.206:3306/test1?useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jackson.serialization.indent_output=true
上述注解使用案列,
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @Configuration //标注一个类是配置类,spring boot在扫到这个注解时自动加载这个类相关的功能,比如前面的文章中介绍的配置AOP和拦截器时加在类上的Configuration@EnableAutoConfiguration() //启用自动配置 该框架就能够进行行为的配置,以引导应用程序的启动与运行, 根据导入的starter-pom 自动加载配置@EnableJpaRepositories(basePackages={"com.dao"})//@EnableJpaRepositories(basePackages={"dao层对应的包路径"})@ComponentScan(value={"com.*","com.dao"})//扫描组件 @ComponentScan(value = "com.spriboot.controller") 配置扫描组件的路径@SpringBootApplication //@EntityScan("entity对应的包路径")@EntityScan("com.entity")public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
- Spring Data JPA配置出现Not a managed type错误
- spring data jpa 出现Not a managed type
- spring data jpa 出现Not a managed type
- spring data jpa 错误 Not an managed type: class java.lang.Object
- Spring-data-jpa报错Not an managed type: class java.lang.Object
- spring boot jpa-java.lang.IllegalArgumentException: Not a managed type异常问题解决方法
- Spring Data jpa异常: Could not determine type for: java.util.List
- Spring + toplink-essentials(JPA) is not a known entity type 问题解决
- 使用spring-data-jpa的时候出现 could not initialize proxy - no Session
- Manual commit is not allowed over a Spring managed
- Manual commit is not allowed over a Spring managed SqlSession
- Spring Data JPA: No property foo found for type Bar
- Spring Data JPA - “No Property Found for Type” Exception
- Spring Data JPA: No property name found for type ×××
- spring整合spring-data-jpa出现aop方面的冲突
- 报错 java.lang.IllegalArgumentException: Not a managed type: class com.yzf.cloud.model.User
- Jpa到Spring data jpa
- Spring-Data-JPA中出现的异常错误处理
- POJ 1509 Glass Beads(最小表示法、后缀自动机)
- byte与其他基本数据类型转换
- pcie驱动介绍
- Java 抽象类
- this 用法简介
- spring data jpa 出现Not a managed type
- Java连接mysql数据库
- LeetCode 71 Simplify Path(Python详解及实现)
- chrome vimium shortcut
- 【清晰明了】A局域网主机向B局域网主机传输数据的过程
- FFMPEG学习【ffplay工具】
- 图论专项菜鸡入门(一):图的储存结构
- activiti学习笔记(一) 获取流程配置实例
- Android Studio 签名文件Gradle安全配置