jpa PropertyReferenceException: No property user found for U

CSDN学院讲师招募,诚邀您加入!博客Markdown编辑器上线啦PMBOK第五版精讲视频教程火星人敏捷开发1001问

jpa PropertyReferenceException: No property user found for User异常

分类:异常

异常jpa

异常详情:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property name found for type User!at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270)at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241)at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76)at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:213)at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:321)at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:301)at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:85)at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:60)at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:91)at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:168)at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:69)at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:320)at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:169)at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:224)at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:210)at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)… 66 more

解决办法:

User findByLoginName(String loginName); 如果采用JPA默认的命名规范,应该写成User findByLoginname(String loginName); 这样会默认找loginname 属性否则findByLoginName 这样找的是Login对象的name属性,,如果不想改名字最好就加上 @Query 注解写清楚

上一篇maven入门教程

顶0踩0

主题推荐猜你在找

查看评论

* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场

核心技术类目

因为你的喜爱会挡也挡不住地流露出来。

jpa PropertyReferenceException: No property user found for U

相关文章:

你感兴趣的文章:

标签云: