首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法将大小解析为类型

无法将大小解析为类型
EN

Stack Overflow用户
提问于 2022-02-11 07:56:59
回答 1查看 606关注 0票数 0

没有找到Size注释,并且I get Size无法解析为 .Although 导入的类型,我得到了这个错误。

进口javax.validation.constraints.Size;

进口lombok.Data;

@Data公共类UserCreateDTO { @Size私有字符串firstName;私有字符串lastName;

}

我在POM.xml中的依赖项是:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2022-02-11 08:09:53

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#validation-starter-no-longer-included-in-web-starters

从#19550开始就不再包含验证启动器,web和WebFlux启动器在默认情况下不再依赖于验证启动器。如果您的应用程序正在使用验证特性,例如,您发现javax.validation.*导入没有得到解决,那么您需要自己添加启动程序。

对于Maven构建,您可以这样做:

代码语言:javascript
复制
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-validation</artifactId>
</dependency>

对于Gradle,您需要添加如下内容:

代码语言:javascript
复制
dependencies {
  ...
  implementation 'org.springframework.boot:spring-boot-starter-validation'
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71076771

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档