在运行Eureka Server应用程序时遇到以下问题,这些是我正在使用的Maven依赖项。请一些机构帮助找到问题。
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0 com.example 演示 0.0.1-快照 演示 Spring Boot的演示项目 org.springframework.boot 弹簧启动启动器父母 2.0.2。发布
<properties>
<java.version>1.8</java.version>
<spring-cloud.version><!-- Greenwich.SR1 --><!-- Camden.SR7 --><!-- Brixton -->Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</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>
这是错误日志
2019-03-16 18:05:45.424 WARN 6568 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'traceFilterRegistration' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'traceFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.servlet.Filter' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value="httpTraceFilter")}
2019-03-16 18:05:45.424信息6568 --- [main] c.n.eureka.DefaultEurekaServerContext:正在关闭... 2019-03-16 18:05:45.424信息6568 --- [main] c.n.eureka.DefaultEurekaServerContext:关闭 2019-03-16 18:05:45.424信息6568 --- [main] com.netflix.discovery.DiscoveryClient:关闭DiscoveryClient ... 2019-03-16 18:05:45.424信息6568 --- [main] com.netflix.discovery.DiscoveryClient:完成关闭DiscoveryClient 2019-03-16 18:05:45.424信息6568 --- [main] o.s.j.e.a.AnnotationMBeanExporter:关机时注销JMX暴露的bean 2019-03-16 18:05:45.456 INFO 6568 --- [main] ConditionEvaluationReportLoggingListener:
启动ApplicationContext时出错。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。 2019-03-16 18:05:45.799错误6568 --- [main] o.s.b.d.LoggingFailureAnalysisReporter:
申请无法开始
说明:
org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration中的traceFilterRegistration方法的参数0要求找不到类型为'javax.servlet.Filter'的bean。 -未加载Bean方法'resourceUrlEncodingFilter',因为它不是servlet Web应用程序 -由于不是servlet Web应用程序,因此未加载Bean方法'characterEncodingFilter' -由于不是servlet Web应用程序,因此未加载Bean方法“ hiddenHttpMethodFilter” -由于不是servlet Web应用程序,因此未加载Bean方法“ httpPutFormContentFilter”
操作:
考虑重新考虑上述条件或在配置中定义类型为“ javax.servlet.Filter”的bean。
答案 0 :(得分:0)
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
*<version>1.5.4.RELEASE</version>*
<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.7</java.version>
*<spring-cloud.version>Dalston.SR1</spring-cloud.version>*
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</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>
通过使用上述依赖性,在对spring父级和云依赖性的不同组合进行了多次试验之后,我能够解决该错误。我相信这是依赖性问题。
答案 1 :(得分:0)
我遇到了类似的问题,并且在我的spring boot项目运行中遇到以下错误:
WARN 18213 --- [restartedMain] ConfigServletWebServerApplicationContext:上下文初始化期间遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreationException:在类路径资源中定义名称为'entityManagerFactory'的bean创建时出错。 / p>
当我升级 Spring-boot-starter-parent版本时,错误消失了,项目运行顺利。
在POM.xml文件中:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
</parent>
更改为:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
</parent>