SpringBoot-错误创建使用名称' DefaultValidator'
我正在创建一个Springboot程序,并且它更早地工作,直到我更改SQL表并添加了列Skipmerge为止。
我的实体课程:
package com.chansoft.Entities;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.springframework.lang.NonNull;
import lombok.Getter;
import lombok.Setter;
@Entity
@Table(name = "files")
@Getter
@Setter
public class FilesEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "fileID")
private Long fileID;
@Column(name = "uploaded", columnDefinition = "tinyint(1)")
@NonNull
private boolean uploaded;
@Column(name = "ocrCompleted", columnDefinition = "tinyint(1)")
@NonNull
private boolean ocrCompleted;
@Column(name = "ocrDownloaded", columnDefinition = "tinyint(1)")
@NonNull
private boolean ocrDownloaded;
@Column(name = "ocrIndexed", columnDefinition = "tinyint(1)")
@NonNull
private boolean ocrIndexed;
@Column(name = "ocrJSONFileName", columnDefinition = "json")
private String ocrJSONFileName;
@Column(name = "fileDirectory", columnDefinition = "varchar(1000)")
private String fileDirectory;
@Column(name = "gcsDirectory", columnDefinition = "varchar(1000)")
private String gcsDirectory;
@Column(name = "isCombined", columnDefinition = "tinyint(1)")
private boolean isCombined;
@Column(name = "skipMerge", columnDefinition = "tinyint(1)")
private boolean skipMerge;
}
我的存储库类:
package com.chansoft.Repositories;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import com.chansoft.Entities.FilesEntity;
@RepositoryRestResource(exported = false)
public interface FilesRepository extends CrudRepository<FilesEntity, Long> {
public List<FilesEntity> findByFileDirectoryIgnoreCase(String FileDirectory);
public List<FilesEntity> findByUploaded(boolean Uploaded);
public List<FilesEntity> findByIsCombinedAndSkipMerge(boolean IsCombined, boolean SkipMerge);
}
有人有线索吗?由于它在没有更改的表之前,它就不会缺少依赖性。我尝试评论实体,存储库,服务和控制器中的跳过部分,但无济于事。
谢谢!
编辑:我将其作为我的stacktrace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultValidator' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError: Receiver class org.hibernate.validator.engine.ConfigurationImpl does not define or inherit an implementation of the resolved method 'abstract javax.validation.ParameterNameProvider getDefaultParameterNameProvider()' of interface javax.validation.Configuration.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.6.jar:2.6.6]
at com.chansoft.PdfOcrReaderApplication.main(PdfOcrReaderApplication.java:10) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.6.6.jar:2.6.6]
Caused by: java.lang.AbstractMethodError: Receiver class org.hibernate.validator.engine.ConfigurationImpl does not define or inherit an implementation of the resolved method 'abstract javax.validation.ParameterNameProvider getDefaultParameterNameProvider()' of interface javax.validation.Configuration.
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.configureParameterNameProvider(LocalValidatorFactoryBean.java:327) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:293) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.18.jar:5.3.18]
... 21 common frames omitted
I am creating a springboot program, and it was working earlier until I altered the SQL table and added a column skipMerge.
My entity class:
package com.chansoft.Entities;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.springframework.lang.NonNull;
import lombok.Getter;
import lombok.Setter;
@Entity
@Table(name = "files")
@Getter
@Setter
public class FilesEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "fileID")
private Long fileID;
@Column(name = "uploaded", columnDefinition = "tinyint(1)")
@NonNull
private boolean uploaded;
@Column(name = "ocrCompleted", columnDefinition = "tinyint(1)")
@NonNull
private boolean ocrCompleted;
@Column(name = "ocrDownloaded", columnDefinition = "tinyint(1)")
@NonNull
private boolean ocrDownloaded;
@Column(name = "ocrIndexed", columnDefinition = "tinyint(1)")
@NonNull
private boolean ocrIndexed;
@Column(name = "ocrJSONFileName", columnDefinition = "json")
private String ocrJSONFileName;
@Column(name = "fileDirectory", columnDefinition = "varchar(1000)")
private String fileDirectory;
@Column(name = "gcsDirectory", columnDefinition = "varchar(1000)")
private String gcsDirectory;
@Column(name = "isCombined", columnDefinition = "tinyint(1)")
private boolean isCombined;
@Column(name = "skipMerge", columnDefinition = "tinyint(1)")
private boolean skipMerge;
}
My repository class:
package com.chansoft.Repositories;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import com.chansoft.Entities.FilesEntity;
@RepositoryRestResource(exported = false)
public interface FilesRepository extends CrudRepository<FilesEntity, Long> {
public List<FilesEntity> findByFileDirectoryIgnoreCase(String FileDirectory);
public List<FilesEntity> findByUploaded(boolean Uploaded);
public List<FilesEntity> findByIsCombinedAndSkipMerge(boolean IsCombined, boolean SkipMerge);
}
Anyone have any clues? Its not missing a dependency since it was working earlier before, without the altered table. I tried commenting out the skipMerge part in the entity, repository, services and controllers to no avail.
Thanks!
Edit: I am getting this as my stacktrace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultValidator' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError: Receiver class org.hibernate.validator.engine.ConfigurationImpl does not define or inherit an implementation of the resolved method 'abstract javax.validation.ParameterNameProvider getDefaultParameterNameProvider()' of interface javax.validation.Configuration.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[spring-boot-2.6.6.jar:2.6.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.6.jar:2.6.6]
at com.chansoft.PdfOcrReaderApplication.main(PdfOcrReaderApplication.java:10) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.6.6.jar:2.6.6]
Caused by: java.lang.AbstractMethodError: Receiver class org.hibernate.validator.engine.ConfigurationImpl does not define or inherit an implementation of the resolved method 'abstract javax.validation.ParameterNameProvider getDefaultParameterNameProvider()' of interface javax.validation.Configuration.
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.configureParameterNameProvider(LocalValidatorFactoryBean.java:327) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:293) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.18.jar:5.3.18]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.18.jar:5.3.18]
... 21 common frames omitted
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
失败与您对实体所做的更改无关。
该异常表明类路径上的 Hibernate Validator 版本与类路径上的 Validation API 版本不兼容。 Hibernate Validator 比 API 更旧,并且没有实现
getDefaultParameterNameProvider
。您可以通过更改 build.gradle 或 pom.xml 来纠正问题。对于 Spring Boot 2.6.6,您应该使用 Hibernate Validator 6.2.3.Final。如果您使用 Spring Boot 的依赖管理,您可以删除构建脚本中的版本,然后它将自动使用 6.2.3.Final。
The failure is unrelated to the change you made to your entity.
The exception indicates that the version of Hibernate Validator on your classpath is not compatible with the version of the Validation API that is on the classpath. Hibernate Validator is older than the API and does not implement
getDefaultParameterNameProvider
.You can correct the problem by changing your build.gradle or pom.xml. With Spring Boot 2.6.6 you should be using Hibernate Validator 6.2.3.Final. If you are using Spring Boot’s dependency management, you can remove the version in your build script and it will then use 6.2.3.Final automatically.