没有找到Size注释,并且I get Size无法解析为 .Although 导入的类型,我得到了这个错误。
进口javax.validation.constraints.Size;
进口lombok.Data;
@Data公共类UserCreateDTO { @Size私有字符串firstName;私有字符串lastName;
}

我在POM.xml中的依赖项是:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>发布于 2022-02-11 08:09:53
从#19550开始就不再包含验证启动器,web和WebFlux启动器在默认情况下不再依赖于验证启动器。如果您的应用程序正在使用验证特性,例如,您发现javax.validation.*导入没有得到解决,那么您需要自己添加启动程序。
对于Maven构建,您可以这样做:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>对于Gradle,您需要添加如下内容:
dependencies {
...
implementation 'org.springframework.boot:spring-boot-starter-validation'
}https://stackoverflow.com/questions/71076771
复制相似问题