以下是代码:
Person.java
@Entity
class Person {
@Id private Long Id;
@NotNull private String name;
//getter setters
}
PersonRepository.java
@RepositoryRestResource(collectionResourceRel = "person", path="person" )
interface PersonRepository extends CrudRepository<Person,Long>{
}
现在,当我将null发送到name属性时,验证器会正确验证,但实际抛出的异常是TransactionRollbackException。
就像这样。
{
"timestamp": "2018-03-14T09:01:08.533+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction",
"path": "/peron"
}
我该如何获取实际的ConstraintViolation异常。我在日志中看到了异常,但它没有被抛出。