springboot Initialization of bean failed; nested exception is javax.validation.ValidationException問題
阿新 • • 發佈:2018-12-16
springboot 1.5.14.RELEASE 讀取自定義配置檔案屬性出現問題
2018-10-19 15:06:11.471 WARN 7884 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nearlineConfig' defined in file [D:\news.recommend\Trunk\news_recommed_reckon_java\recommend_result\recommend_new\recommend_nearline\target\classes\com\tnaot\recommend_nearline\base\config\NearlineConfig.class]: Initialization of bean failed; nested exception is javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath. 2018-10-19 15:06:11.477 INFO 7884 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-10-19 15:06:11.484 ERROR 7884 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: The Bean Validation API is on the classpath but no implementation could be found Action: Add an implementation, such as Hibernate Validator, to the classpath
解決辦法,在pom.xml新增以下依賴:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.2.1.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator-annotation-processor</artifactId> <version>5.2.1.Final</version> </dependency>