当前位置: 首页 > 知识库问答 >
问题:

无法将大小解析为类型

宿丰
2023-03-14

找不到大小注释,我得到大小不能解析为类型。虽然添加了导入javax.validation.constraints.大小;,但我得到了这个错误。

导入javax。验证。限制。大小

导入lombok.数据;

@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>

共有1个答案

商俊智
2023-03-14

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#validation-starter不再包含在web starter中

验证启动器不再包含在Web启动器中从#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'
}
 类似资料:
  • 问题内容: 这是我得到的错误: 这是我的代码: 另外,我在一个单独的类中声明了这一点: 是什么导致此错误,我该如何解决? 编辑:缩进,空格,命名约定和可读性问题已得到解决。 问题答案: 问题在于,这似乎是一个内部类(很难说,您的缩进是不好的),并且由于它不是静态的,因此您无法单独实例化它。 您要么需要自己创建一个类,要么使其成为一个类并将其实例化为(或者无论父类是什么,您的缩进在这里实际上都没有帮

  • 问题内容: 尝试遵循本教程:教程 尝试像这样使用 JSONParser : 但是Eclipse给了我。 该怎么办? 问题答案: JSONParser类在本教程的下方,它看起来像这样…… 我会考虑看看杰克逊图书馆通过http://jackson.codehaus.org/

  • 我正在尝试将主题添加到我的项目中。它需要appcompat v7。 我按照Android开发者网站中提到的步骤添加了支持库。经过大量搜索,我知道支持库v4将与支持库v7冲突。 所以我从我的项目中删除了android库v4。因此,现在我得到了t错误()。 我必须做什么?请有人帮我解决这个问题。预先感谢

  • 在我的testrunner类中,当使用时,我收到一条错误消息,说“cucumberoptions不能解析为类型”。我使用的是最新版本的eclipse cucumber依赖项。通过安装和卸载eclipse,通过降低cucumber依赖项版本,我已经尝试了所有可能的方法。 我的跑者班是:

  • 我创建了一个RunTest类来使用Cucumber和JUnit运行测试场景。要运行之前的测试,我需要将RunWith类(@RunWith)导入到我的项目中,并将Cucumber.class作为参数传递。然后,类的RunWith参数识别更多传递给它的参数,不。eclipse将显示以下消息: 无法将此行类中的多个标记解析为类型。-Cucumber无法解析为类型。-注释@runwith必须定义属性值 我

  • 我试图在我的Spring Boot(使用Swagger)中构建一个简单的断路器。 但它给出了同样的错误,“无法解决”。