Caused by: org.springframework.data.mapping

刚刚在用spring boot + jpa的时候出现一个问题,就是报错No property name found for type User!。看了一下;后面发现了一个坑,现在记录一下提醒一下

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property name found for type User!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76)
at org.springframework.data.repository.query.parser.PartTreeOrPart.&lt;init&gt;(PartTree.java:247)<br><span style="white-space:pre;"></span>at org.springframework.data.repository.query.parser.PartTreePredicate.buildTree(PartTree.java:398)
at org.springframework.data.repository.query.parser.PartTreePredicate.&lt;init&gt;(PartTree.java:378)<br><span style="white-space:pre;"></span>at org.springframework.data.repository.query.parser.PartTree.&lt;init&gt;(PartTree.java:89)<br><span style="white-space:pre;"></span>at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.&lt;init&gt;(PartTreeJpaQuery.java:64)<br><span style="white-space:pre;"></span>at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategyCreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:103)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:214)<br><spanstyle="whitespace:pre;"></span>atorg.springframework.data.jpa.repository.query.JpaQueryLookupStrategy AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:77)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:436)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:221)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:101)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
… 29 common frames omitted


===解决办法============

原因是在UserRepository中用的方法是:User findByName(String userName);


按照jpa的规范这个就是去找User类的name属性去查询,而我的User的类实体是


所以就找不到了;报错了。

现在就是改成:User findByUserName(String userName);

这样就可以了!

这个解决办法是参考l :http://www.iteye.com/topic/1127339

刚刚入门spring boot+jpa;坑很多;一步步踩;一步步学习了!!描述不对的欢迎指正


                </div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Caused by: org.springframework.beans.TypeMismatchException 是一个由Spring框架引发的异常。该异常通常在应用程序中出现时,表示在自动装配(autowiring)依赖项时类型不匹配。 具体来说,当Spring容器尝试将一个bean注入到另一个bean时,它会检查它们的类型是否匹配。如果类型不匹配,就会抛出TypeMismatchException异常。 这个异常的出现可能由多种原因引起,比如: 1. 在配置文件中指定的bean类型与实际的bean类型不匹配。 2. 在注解中指定的依赖类型与实际的依赖类型不匹配。 3. 使用了错误的自动装配模式。 要解决这个问题,你可以按照以下步骤进行操作: 1. 检查配置文件或注解中的bean定义,确保指定的类型与实际的类型匹配。 2. 检查是否存在其他相同名称但类型不匹配的bean定义。 3. 检查是否使用了正确的自动装配模式,比如按名称(byName)或按类型(byType)进行装配。 通过对配置文件和代码的仔细检查,你应该能够找到并解决引发TypeMismatchException异常的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [错误TypeMismatchException: Failed to convert property value of type [java.lang解决与原因?](https://blog.csdn.net/luo609630199/article/details/82821758)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [SpringBoot启动报错:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating...](https://blog.csdn.net/Faker_News/article/details/111710850)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.Transformer异常](https://download.csdn.net/download/weixin_38642864/12723222)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值