Java 在 Spring Boot 应用程序中启动 ApplicationContext 时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43626225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 01:04:27  来源:igfitidea点击:

Error starting ApplicationContext in Spring Boot App

javaspringspring-mvcspring-bootspring-bean

提问by Kumaresh Babu N S

I am trying with simple spring boot application. I am facing problem on starting an application on ApplicationContext.

我正在尝试使用简单的 Spring Boot 应用程序。我在 ApplicationContext 上启动应用程序时遇到问题。

2017-04-26 11:17:31.101 WARN 14528 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'standardHymansonObjectMapperBuilderCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/Hymanson/HymansonAutoConfiguration$Hymanson2ObjectMapperBuilderCustomizerConfiguration.class]: Unsatisfied dependency expressed through method 'standardHymansonObjectMapperBuilderCustomizer' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.Hymanson-org.springframework.boot.autoconfigure.Hymanson.HymansonProperties': 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. 2017-04-26 11:17:31.116 INFO 14528 --- [ main] utoConfigurationReportLoggingInitializer :

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2017-04-26 11:17:31.121 ERROR 14528 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

2017-04-26 11:17:31.101 WARN 14528 --- [main] scaAnnotationConfigApplicationContext:上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为 'standardHymanson'ObjectMap 的 bean 时出错类路径资源[org/springframework/boot/autoconfigure/Hymanson/HymansonAutoConfiguration$Hymanson2ObjectMapperBuilderCustomizerConfiguration.class]:通过方法'standardHymansonObjectMapperBuilderCustomizer'参数1表示的不满足的依赖;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“spring.Hymanson-org.springframework.boot.autoconfigure.Hymanson.HymansonProperties”的 bean 时出错:bean 初始化失败;嵌套异常是 javax.validation.ValidationException:无法创建配置,因为找不到 Bean 验证提供程序。将像 Hibernate Validator (RI) 这样的提供程序添加到您的类路径中。2017-04-26 11:17:31.116 INFO 14528 --- [主要] utoConfigurationReportLoggingInitializer :

启动 ApplicationContext 时出错。要显示自动配置报告,请在启用“调试”的情况下重新运行您的应用程序。2017-04-26 11:17:31.121 错误 14528 --- [主要] osbdLoggingFailureAnalysisReporter:

I got above errors while starting an application. I am using spring boot 1.5.1.RELEASE version.

启动应用程序时出现上述错误。我正在使用 spring boot 1.5.1.RELEASE 版本。

Kindly do needful.

请有需要的。

EDIT 1enter image description here

编辑 1在此处输入图片说明

EDIT 2

编辑 2

package com.hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class HelloWorld{

public static void main(String[] args) {
    // TODO Auto-generated method stub
    SpringApplication.run(HelloWorld.class, args);
}

}

采纳答案by Kumaresh Babu N S

I solved the problem by excluding hibernate-validator dependency in pom.xml. It is working fine without any issues.

我通过在 pom.xml 中排除 hibernate-validator 依赖解决了这个问题。它工作正常,没有任何问题。

回答by Sudhakar

It seems like Hymanson libraries not available for this boot project. Either add Hymanson libraries manually or add the following dependencies which will internally import Hymanson libraries.

似乎Hyman逊库不适用于此启动项目。手动添加 Hymanson 库或添加以下将在内部导入 Hymanson 库的依赖项。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <name>helloWorld</name>
    <version>0.0.0-SNAPSHOT</version>
    <groupId>com.test</groupId>
    <artifactId>test</artifactId>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.1.RELEASE</version>
    </parent>

    <packaging>jar</packaging>

    <properties>
        <dozer.version>5.4.0</dozer.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-feign</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Camden.SR5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

回答by Neethi P

Resolved the issue by adding the below dependency for Hymanson:

通过为 Hymanson 添加以下依赖项解决了该问题:

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-autoconfigure</artifactId>
      <version>1.2.1.RELEASE</version> 
</dependency>

Also make sure to remove classpath entries for Hymanson

还要确保删除Hyman逊的类路径条目