转自:https://blog.csdn.net/lzx925060109/article/details/40323741

1、

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentServiceBean': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract boxfish.bean.Student boxfish.service.StudentServiceBean.find(java.lang.String)!

原因:bean类中的扩展查询方法的query语句中的sql语句存在错误。

查询语句应该为select    s   from  Student s where s.id=?1这种样式。其中表明Stduent必须和实体类名完全相同,否则报错。

2、Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query。

原因:事务需求异常。或许是业务逻辑类为注解为@Transactional

样例:

@Repository
@Transactional
public interface StudentServiceBean extends JpaRepository<Student,Long> {
    @Query("select s from Student s where s.username=?1")
    public Student find(String username);
    @Modifying
    @Query("update Student s set s.password=?1 where s.id=?2")
    public int update(String password, Long id);
}

Validation failed for query for method public abstract boxfish.bean.Student boxfish.service.StudentServiceBean.find(java.lang.String)!的更多相关文章

  1. Validation failed for query for method

    问题原因 sql语法,使用@Query("select id, username, usersex, userphone from User where User.usersex = ?1& ...

  2. Hint: Fallback method 'public java.lang.String queryUserByIdFallback(java.lang.Long)' must return: User or its subclass

    1.错误日志 熔断器添加错误方法返回时,报了一个 error. com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionExc ...

  3. 解决spring mvc 上传报错,Field [] isn't an enum value,Failed to convert value of type 'java.lang.String[]' to required type '

    没有选择附件,但是点击上传按钮的时候会报错. 之前不选择文件,直接上传空文件是可以的,后来不知道改了什么就不行了. 错误信息: -- :: [http--] TRACE org.springframe ...

  4. Failed to convert from type [java.lang.String] to type [java.util.Date] for value '2020-02-06'; nested exception is java.lang.IllegalArgumentException]解决

    今天做springbook项目前端输入日期传到数据库保存报了一下错误 Whitelabel Error Page This application has no explicit mapping fo ...

  5. 【spring mvc】后台API查询接口,get请求,后台Date字段接收前台String类型的时间,报错default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'createDate';

    后台API查询接口,get请求,后台Date字段接收前台String类型的时间筛选条件 后台接口接收 使用的实体 而createDate字段在后台实体中是Date类型 报错信息: org.spring ...

  6. Java 异常 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date'

    查询时发送给服务器的日期的字符串格式:yyyy-MM-dd HH:mm:ss 服务器接收到日期的字符串之后,向 MySQL 数据库发起查询时,因为没有指定日期时间格式,导致字符串数据不能正确地转换为日 ...

  7. 【spring boot】spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [java.util.Date]

    spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [jav ...

  8. spring mvc出现 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'endtime'

    在使用spring mvc中,绑定页面传递时间字符串数据给Date类型是出错: Failed to convert property value of type [java.lang.String] ...

  9. 出错:Failed to convert property value of type 'org.apache.ibatis.session.defaults.DefaultSqlSessionFactory' to required type 'java.lang.String' for property 'sqlSessionFactoryBeanName';

    出错的详细信息: 3 ERROR [http-nio-80-exec-3] org.springframework.web.servlet.DispatcherServlet - Context in ...

随机推荐

  1. 【Henu ACM Round #13 A】 Hulk

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟. [代码] #include <bits/stdc++.h> using namespace std; int m ...

  2. CodeForcesGym 100502K Train Passengers

    Train Passengers Time Limit: 1000ms Memory Limit: 524288KB This problem will be judged on CodeForces ...

  3. 洛谷 P2117 小Z的矩阵

    P2117 小Z的矩阵 题目描述 小Z最近迷上了矩阵,他定义了一个对于一种特殊矩阵的特征函数G.对于N*N的矩阵A,A的所有元素均为0或1,则G(A)等于所有A[i][j]*A[j][i]的和对2取余 ...

  4. 设置select组件中的默认值

    会员卡类型   <select id="name2" style="width:140px"> <option value="Ak& ...

  5. 1.Maven之(一)Maven是什么

    转自:https://blog.csdn.net/xhxmister/article/details/79409208 首先,Maven的正确发音是[ˈmevən],而不是“马瘟”以及其他什么瘟.Ma ...

  6. vue 引入第三方字体包

    1.创建 style_css 文件夹,在当前文件夹下 新建 index.css  和  引入字体包. 2. 在build 目录下,设置 webpack.base.cong.js ,  在module ...

  7. 63.C++异常

    #include <iostream> using namespace std; //异常与错误不一样,异常一般能正常工作 //错误就是程序无法正常工作,无法编译 //异常让程序在错误的输 ...

  8. JS错误记录 - dom操作 - 排序

    本次练习错误总结: 1. for循环要套到按钮的onclick里面,否则onclick点击事件无法依次执行. 2. var n1, var n2 这两个变量是arr.sort排序使用的,所以应该放在s ...

  9. MyBatis学习总结(11)——MyBatis动态Sql语句

    MyBatis中对数据库的操作,有时要带一些条件,因此动态SQL语句非常有必要,下面就主要来讲讲几个常用的动态SQL语句的语法 MyBatis中用于实现动态SQL的元素主要有: if choose(w ...

  10. Android学习笔记技巧之给文本加边框

    BorderTextViews.Java package xiaosi.BorderTextView; import android.content.Context; import android.g ...