繁体   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