>  기사  >  Java  >  springBoot 통합 Eureka 시작 실패를 해결하는 방법

springBoot 통합 Eureka 시작 실패를 해결하는 방법

王林
王林앞으로
2023-05-31 17:43:181316검색

사실 springBoot를 Eureka와 통합하는 것은 상대적으로 간단하지만 통합 후에 많은 사람들이 시작할 수 없다는 것을 알게 되었습니다. 여기에 오류 보고에 대한 보다 일반적인 이유를 나열하겠습니다.

보고서: 시작 중에 하위 컨테이너가 실패했습니다

아래와 같이

springBoot 통합 Eureka 시작 실패를 해결하는 방법

이 이유는 pom.xml이 추가되지 않았기 때문입니다

<dependencymanagement>
        <dependencies>
            <dependency>
                <groupid>org.springframework.cloud</groupid>
                <artifactid>spring-cloud-dependencies</artifactid>
                <version>Finchley.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencymanagement>

추가 후에도 여전히 오류가 보고되는 경우:

springBoot 통합 Eureka 시작 실패를 해결하는 방법

오류의 원인은 Springboot 및 SpringCloud 버전 때문입니다. 일치하지 않습니다

springBoot 통합 Eureka 시작 실패를 해결하는 방법

springBoot 통합 Eureka 시작 실패를 해결하는 방법

수정 후 정상적으로 실행됩니다! 마지막으로 해당 버전을 게시하고 해당 springboot 버전을 보고 springCloud

Spring Boot Spring Cloud
1.2.x Angel 버전
1.3.x Brixton 버전
1.4.x Camden 버전
1.5.x Dalston 버전을 변경할 수 있습니다. Edgware 버전
2.0.x Finchley 버전

SpringCloud 예외(Euruka)

Application run failed java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder

Euruka를 서비스 등록 센터로 테스트하다 보니 이 문제의 경우 오류 메시지는 다음과 같습니다.

"C:\Program Files\Java\jdk1.8.0_161\bin\java" -XX:TieredStopAtLevel=1 -........ com.fangxing.springcloud.eurukaserver.EurukaServerApplication
15:04:35.690 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: ....... file:/D:/Program%20Files/JetBrains/IntelliJ%20IDEA%202017.3.5/lib/idea_rt.jar]
15:04:35.867 [background-preinit] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4j2LoggerProvider
15:04:35.869 [background-preinit] INFO org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.0.7.Final
15:04:35.884 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Cannot find javax.persistence.Persistence on classpath. Assuming non JPA 2 environment. All properties will per default be traversable.
15:04:35.890 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
15:04:35.892 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via TCCL
15:04:35.893 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via Hibernate Validator's class loader
15:04:35.894 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - No META-INF/validation.xml found. Using annotation based configuration only.
15:04:36.086 [background-preinit] DEBUG org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator as ValidatorFactory-scoped message interpolator.
15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.TraverseAllTraversableResolver as ValidatorFactory-scoped traversable resolver.
15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.
15:04:36.404 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:120)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:84)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:62)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:351)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
    at com.fangxing.springcloud.eurukaserver.EurukaServerApplication.main(EurukaServerApplication.java:16)
Process finished with exit code 1</init>

근본 원인은 종속 패키지의 버전 충돌입니다. 내 pom.xml 파일은 다음과 같습니다.

<?xml  version="1.0" encoding="UTF-8"?>
<project>
    <modelversion>4.0.0</modelversion>
    <groupid>com.fangxing.springcloud</groupid>
    <artifactid>euruka-server</artifactid>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>euruka-server</name>
    <description>Demo project for Eureka Server</description>
    <parent>
        <groupid>org.springframework.boot</groupid>
        <artifactid>spring-boot-starter-parent</artifactid>
        <version>2.0.0.RELEASE</version>
        <relativepath></relativepath> <!-- lookup parent from repository -->
    </parent>
    <properties>
        <project.build.sourceencoding>UTF-8</project.build.sourceencoding>
        <project.reporting.outputencoding>UTF-8</project.reporting.outputencoding>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-starter-web</artifactid>
        </dependency>
        <dependency>
            <groupid>org.springframewor k.boot</groupid>
            <artifactid>spring-boot-starter-test</artifactid>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupid>org.springframework.cloud</groupid>
            <artifactid>spring-cloud-starter-eureka-server</artifactid>
        </dependency>
    </dependencies>
    <dependencymanagement>
        <dependencies>
            <dependency>
                <groupid>org.springframework.cloud</groupid>
                <artifactid>spring-cloud-dependencies</artifactid>
                <version>Camden.SR3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencymanagement>
    <build>
        <plugins>
            <plugin>
                <groupid>org.springframework.boot</groupid>
                <artifactid>spring-boot-maven-plugin</artifactid>
            </plugin>
        </plugins>
    </build>
</project>

여기서 사용된 SpringBoot 버전은 2.0.0.0이므로 조정합니다. 버전을 확인하시고 아래의 pom.xml

<?xml  version="1.0" encoding="UTF-8"?>
<project>
    <modelversion>4.0.0</modelversion>
    <groupid>com.fangxing.springcloud</groupid>
    <artifactid>euruka-server</artifactid>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>euruka-server</name>
    <description>Demo project for Eureka Server</description>
    <!--基于Springboot-->
    <parent>
        <groupid>org.springframework.boot</groupid>
        <artifactid>spring-boot-starter-parent</artifactid>
        <version>1.4.0.RELEASE</version>
        <relativepath></relativepath>
    </parent>
    <properties>
        <!--设置字符编码及java版本-->
        <project.build.sourceencoding>UTF-8</project.build.sourceencoding>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <!--增加eureka-server的依赖-->
        <dependency>
            <groupid>org.springframework.cloud</groupid>
            <artifactid>spring-cloud-starter-eureka-server</artifactid>
        </dependency>
        <!--用于测试的,本例可省略-->
        <dependency>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-starter-test</artifactid>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <!--依赖管理,用于管理spring-cloud的依赖,其中Camden.SR3是版本号-->
    <dependencymanagement>
        <dependencies>
            <dependency>
                <groupid>org.springframework.cloud</groupid>
                <artifactid>spring-cloud-dependencies</artifactid>
                <version>Camden.SR3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencymanagement>
    <build>
        <plugins>
            <plugin>
                <groupid>org.springframework.boot</groupid>
                <artifactid>spring-boot-maven-plugin</artifactid>
            </plugin>
        </plugins>
    </build>
</project>

을 이용하시면 정상적으로 활성화가 가능합니다.

위 내용은 springBoot 통합 Eureka 시작 실패를 해결하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 yisu.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제