使用H2进行Javax验证

时间:2017-12-19 23:13:08

标签: java spring h2

我有这个测试

@Test
public void mustPostAccountCreationExceptionWithMoreThanTwoDigitsAfterComma(){
    thrown.expect(ConstraintViolationException.class);

    account.setSaldo(new BigDecimal("12.000"));
    accountRepository.save(account);
}

对字段saldo的验证:

@Digits(fraction = 2, integer = 9)
private BigDecimal saldo;

但是H2不起作用而且Postgresql正常工作

1 个答案:

答案 0 :(得分:0)

在pom.xml中添加:

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.196</version>
<scope>test</scope>

并删除Postgresql的config-beans 或者把你的项目发给我,我可以帮助你

相关问题