簡體   English   中英

錯誤:應用程序運行失敗,嘗試實現服務發現尤里卡

[英]Error : Application run failed , trying to implement Service discovery Eureka

我有一個非常簡單的演示應用程序,我用它來注冊 Eureka 服務器。 但我收到以下錯誤。 我已經能夠成功注冊另一個演示應用程序,但這個失敗了:

這是錯誤消息:

12:29:07.678 [restartedMain] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - 應用程序無法以類路徑啟動:[文件:/Users/test/Downloads/demorest/target/classes/] 12:29:07.728 [background-preinit] DEBUG org.jboss.logging - 日志提供程序:org.jboss.logging.Log4j2LoggerProvider 12:29:07.729 [background-preinit] INFO org.hibernate.validator.internal.util.Version - HV000001: Hibernate.0 Validator .14.Final 12:29:07.736 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - 在類路徑上找不到 javax.persistence.Persistence。 假設非 JPA 2 環境。 默認情況下,所有屬性都是可遍歷的。 12:29:07.741 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ValidationXmlParser - 嘗試為基於 XML 的驗證器配置加載 META-INF/validation.xml。 12:29:07.743 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ResourceLoaderHelper - 嘗試通過 TCCL 加載 META-INF/validation.xml 12:29:07.744 [background-preinit] DEBUG org。 hibernate.validator.internal.xml.config.ResourceLoaderHelper - 嘗試通過 Hibernate Validator 的類加載器加載 META-INF/validation.xml 12:29:07.744 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config。 ValidationXmlParser - 未找到 META-INF/validation.xml。 僅使用基於注釋的配置。 12:29:07.939 [background-preinit] DEBUG org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator - 通過原始 TCCL 加載表達式工廠 12:29:07.944 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryI HV000234:使用 org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator 作為 ValidatorFactory 范圍的消息內插器。 12:29:07.944 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234:使用 org.hibernate.validator.internal.engine.resolver.TraverseAllTraversableResolver 作為 ValidatorFactory 范圍的可遍歷解析器。 12:29:07.945 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234:使用 org.hibernate.validator.internal.util.ExecutableParameterNameProvider 作為 ValidatorFactory 范圍的參數名稱提供程序。 12:29:07.945 [background-preinit] 調試 org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234:使用 org.hibernate.validator.internal.engine.DefaultClockProvider 作為 ValidatorFactory 范圍的時鍾提供程序。 12:29:07.945 [background-preinit] 調試 org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234:使用 org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory 作為 ValidatorFactory 范圍的腳本評估器工廠。 12:29:08.513 [restartedMain] 錯誤 org.springframework.boot.SpringApplication - 應用程序運行失敗 java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.([Ljava/lang/Object;)V at org.springframework .cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:161) at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102) at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onstrapApplication. :68) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) 在 org.springframework. SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) 在 org.spring framework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) 在 org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75) 在 org.springframework.boot.SpringApplicationRunListeners.environmentPrepared. java:54) 在 org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:306) 在 org.springframework.boot.SpringApplication.run(SpringApplication) .java:1260) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) 在 com.example.rest.demorest.DemorestApplication.main(DemorestApplication.java:15) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)

如果沒有 Eureka,同一個項目也能順利開始。

   <?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>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.2.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.rest</groupId>
<artifactId>demorest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demorest</name>
<description>Demo project for Spring Boot</description>

<properties>
    <java.version>1.8</java.version>
</properties>

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


    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        <version>1.4.6.RELEASE</version>
    </dependency>


    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

</dependencies>

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

應用程序屬性:

    spring.application.name=demorest
    eureka.client.service-url.defaultZone=http://localhost:8761/eureka

應用類:

@EnableDiscoveryClient
@SpringBootApplication
public class DemorestApplication {

public static void main(String[] args) {
    ApplicationContext ctx = SpringApplication.run(DemorestApplication.class, args);

    String[] beanNames = ctx.getBeanDefinitionNames();
    //Arrays.sort(beanNames);

    for(String name : beanNames)
        System.out.println(name);
}

}

除了通過給出的答案奔摹,春季雲春季啟動應該可以找到兼容的版本在這里表1.釋放列車春天啟動的兼容性

例如:Spring Boot 2.6.1 和 Spring Cloud 2021.0.0 可以一起使用如下:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.1</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM