spring data jpa 出现Not a managed type
来源:互联网 发布:linux 手动开启服务 编辑:程序博客网 时间:2024/05/21 03:25
这几天看自己买的那本spring boot的书,学些spring boot,spring boot零配置还是挺好用的,当看到spring data jpa时,我想自己写一下,spring data jpa 还是挺好用的,其中的那个写jpa对应的dao层,只需要extends JpaRepository<实体, 实体对应的主键>,然后在接口上用@Query写对应的hql语句,这点我觉得快赶上mybatis的灵活性了,在其他层注入的时候发现注入不进去,经自己一中午的查资料和实践发现,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://IP:port/库
spring.datasource.username = 用户名
spring.datasource.password = 密码
spring.datasource.driverClassName = com.mysql.jdbc.Driver
# Specify the DBMS
spring.jpa.database = MYSQL
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
#spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# stripped before adding them to the entity manager)
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
- 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中出现的异常错误处理
- 生成二维码图标
- windows条件变量
- html元素添加和移除class属性
- 解决浏览器记住密码输入框的问题
- 记录
- spring data jpa 出现Not a managed type
- UML——在Visual Studio 2013/2015中设计UML类图
- 每天一个linux命令目录
- test
- 将某个目录下所有ko文件反汇编
- jeecms txt 文本 默认带<p>标签 如何变成纯文本 不要任何格式
- Android Studio常用代码模版,让编码飞起来 template
- linux 下vim中关于删除某段,某行,或者全部删除的命令
- Java并发系列-4、并发编程模型