须要留神:高版本idea中应用@NotBlank会呈现注解标红提醒找不到此注解!!!
须要在pom.xml中引入validation后应用。
来源gao.dai.ma.com搞@代*码网
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency>
@NotBlank:只能作用在String上,不能为null,而且调用trim()后,长度必须大于0
留神在应用@NotBlank等注解时,肯定要和@valid一起应用,不然@NotBlank不起作用