在spring-boot网络应用中, 当我使用@PastOrPresent时,STS向我显示了这个错误:
(PastOrPresent无法解析为某种类型)
但是org.springframework.boot:spring-boot-starter-validation条目已经属于依赖项。
Gradle文件
buildscript {
ext {
springBootVersion = '1.5.9.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.domain'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-actuator-docs')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-validation')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.springframework.boot:spring-boot-devtools')
runtime('org.postgresql:postgresql')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}
Gradle文件的更新
...
compile('org.springframework.boot:spring-boot-starter-validation'){
exclude group: 'org.hibernate', module: 'hibernate-validator:5.3.6.Final'
}
compile 'org.hibernate:hibernate-validator:6.0.7.Final'
...
| \--- org.hibernate:hibernate-validator:5.3.6.Final -> 6.0.7.Final
| \--- org.hibernate.validator:hibernate-validator:6.0.7.Final
| +--- javax.validation:validation-api:2.0.1.Final -> 1.1.0.Final
| +--- org.jboss.logging:jboss-logging:3.3.0.Final -> 3.3.1.Final
| \--- com.fasterxml:classmate:1.3.1 -> 1.3.4
还有别的事可做吗?虽然在实体内部我仍然有同样的错误。使用新的:NotEmpty类型已弃用(显示文档here)