使用SpringData JPA时发现使用save的方法会报错:javax.validation.ValidationException: HV000183。
源码:
public interface CustomerDao extends JpaRepository<Customer,Long> ,JpaSpecificationExecutor<Customer> {
}
test代码:
@Test
public void TestSave(){
Customer customer = new Customer();
customer.setCustName("百度");
customer.setCustIndustry("c++开发");
customerDao.save(customer);
}
这时候保存不到数据库,此时在pom.xml的配置文件添加依赖
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.1.Final</version>
</dependency>
这样既可解决。