错误:应用程序运行失败,尝试实施服务发现Eureka

时间:2019-03-25 16:47:37

标签: java netflix-eureka

我有一个非常简单的演示应用程序,用于向Eureka服务器注册。但是我收到以下错误。我已经能够成功注册另一个演示应用程序,但这失败了:

这是错误消息:

  

12:29:07.678 [restartedMain]调试org.springframework.boot.context.logging.ClasspathLoggingApplicationListener-应用程序无法以类路径启动:[文件:/用户/测试/下载/ demorest /目标/类/]   12:29:07.728 [background-preinit]调试org.jboss.logging-记录提供程序:org.jboss.logging.Log4j2LoggerProvider   12:29:07.729 [background-preinit]信息org.hibernate.validator.internal.util.Version-HV000001:Hibernate Validator 6.0.14.Final   12:29:07.736 [background-preinit]调试org.hibernate.validator.internal.engine.resolver.TraversableResolvers-在类路径上找不到javax.persistence.Persistence。假设非JPA 2环境。默认情况下,所有属性都是可遍历的。   12:29:07.741 [background-preinit]调试org.hibernate.validator.internal.xml.config.ValidationXmlParser-尝试加载基于XML的Validator配置的META-INF / validation.xml。   12:29:07.743 [background-preinit]调试org.hibernate.validator.internal.xml.config.ResourceLoaderHelper-尝试通过TCCL加载META-INF / validation.xml   12:29:07.744 [background-preinit]调试org.hibernate.validator.internal.xml.config.ResourceLoaderHelper-尝试通过Hibernate Validator的类加载器加载META-INF / validation.xml   12:29:07.744 [background-preinit]调试org.hibernate.validator.internal.xml.config.ValidationXmlParser-未找到META-INF / validation.xml。仅使用基于注释的配置。   12:29:07.939 [background-preinit]调试org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator-通过原始TCCL加载了表达式工厂   12:29:07.944 [background-preinit]调试org.hibernate.validator.internal.engine.ValidatorFactoryImpl-HV000234:使用org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator作为ValidatorFactory范围内的消息插补器。   12:29:07.944 [background-preinit]调试org.hibernate.validator.internal.engine.ValidatorFactoryImpl-HV000234:将org.hibernate.validator.internal.engine.resolver.TraverseAllTraversableResolver用作ValidatorFactory范围内的可遍历解析器。   12:29:07.945 [background-preinit]调试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       在org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:161)       在org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102)       在org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:68)       在org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)       在org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)       在org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)       在org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)       在org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)       在org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.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(本机方法)处       在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)       在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>

application.properties:

    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);
}

}

0 个答案:

没有答案
相关问题