- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
创建了一个Spring Boot应用程序示例项目以了解伪客户端功能,在运行时会出现以下错误。
说明:
com.example.demo.RestClient中的字段remoteCallClient需要找不到“com.example.demo.RemoteCallClient”类型的Bean。
行动:
考虑在配置中定义类型为“com.example.demo.RemoteCallClient”的bean。
我提供了示例项目的完整源代码,但尝试了各种方法,但仍无法解决。
POM.xml
<?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>
<groupId>com.example</groupId>
<artifactId>mictro-service-3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>micro-service-3</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.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.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.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>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-feign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
<version>1.4.5.RELEASE</version>
</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>
</project>
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableFeignClients
public class MicroService3Application {
public static void main(String[] args) {
SpringApplication.run(MicroService3Application.class, args);
}
}
package com.example.demo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
@FeignClient(url="https://jsonplaceholder.typicode.com/",value="USERS")
public interface RemoteCallClient {
@RequestMapping("users")
public String getUsers();
}
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class RestClient {
@Autowired
private RemoteCallClient remoteCallClient;
public String getRemoteClient() {
return remoteCallClient.getUsers();
}
}
2018-07-23 11:22:57.668 INFO 6556 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4efbca5a: startup date [Mon Jul 23 11:22:57 PDT 2018]; root of context hierarchy
2018-07-23 11:22:57.852 INFO 6556 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-23 11:22:57.877 INFO 6556 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$62660f56] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.3.RELEASE)
2018-07-23 11:22:58.066 INFO 6556 --- [ main] c.example.demo.MicroService3Application : No active profile set, falling back to default profiles: default
2018-07-23 11:22:58.075 INFO 6556 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6b58b9e9: startup date [Mon Jul 23 11:22:58 PDT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4efbca5a
2018-07-23 11:22:58.712 INFO 6556 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=27c00c1a-419a-35b3-9b1b-f3a4f9bbf439
2018-07-23 11:22:58.726 INFO 6556 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-23 11:22:58.800 INFO 6556 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$62660f56] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-23 11:22:58.992 INFO 6556 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-07-23 11:22:59.006 INFO 6556 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-23 11:22:59.006 INFO 6556 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-23 11:22:59.009 INFO 6556 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_92\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_92/bin/server;C:/Program Files/Java/jre1.8.0_92/bin;C:/Program Files/Java/jre1.8.0_92/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_92\bin;C:\Program Files (x86)\Skype\Phone\;C:\apache-tomcat\bin\;F:\apache-maven-3.5.0\bin;;E:\eclipse\oxygen\eclipse;;.]
2018-07-23 11:22:59.165 INFO 6556 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-07-23 11:22:59.165 INFO 6556 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1090 ms
2018-07-23 11:22:59.371 WARN 6556 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2018-07-23 11:22:59.371 INFO 6556 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2018-07-23 11:22:59.379 INFO 6556 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@156f04f8
2018-07-23 11:23:00.180 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-07-23 11:23:00.183 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpTraceFilter' to: [/*]
2018-07-23 11:23:00.184 INFO 6556 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2018-07-23 11:23:00.209 WARN 6556 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'restClient': Unsatisfied dependency expressed through field 'remoteCallClient'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.demo.RemoteCallClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2018-07-23 11:23:00.210 WARN 6556 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method 'close' failed on bean with name 'eurekaRegistration': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
2018-07-23 11:23:00.212 INFO 6556 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-07-23 11:23:00.225 INFO 6556 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-23 11:23:00.353 ERROR 6556 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field remoteCallClient in com.example.demo.RestClient required a bean of type 'com.example.demo.RemoteCallClient' that could not be found.
Action:
Consider defining a bean of type 'com.example.demo.RemoteCallClient' in your configuration.
最佳答案
在假冒依赖项下使用
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
关于spring-boot - Spring Boot应用程序无法自动连接假客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51485179/
我注意到一些 PHP 框架只使用小写字母 true/false 而其他框架则使用大写字母。 这有什么区别吗?我个人更喜欢小写字母。 最佳答案 没什么区别,有些人认为 FALSE 是常量,因此使用旧的尖
在我看来,以下两种映射方式实际上没有区别。以下是基于 @MapsId javadoc 的示例: // parent entity has simple primary key @Entity publ
我想知道是否有人知道编译器如何解释以下代码: #include using namespace std; int main() { cout << (true && true || false &
我想知道为什么alert(new Boolean(false))打印 false 而不是打印对象,因为 new Boolean 应该返回对象。如果我使用 console.log(new Boolean
即使在 verify=False 时,Python 请求也会给我一个 ssl 握手失败(我知道不使用 SSL 是不可取的)。对于其他具有有效证书的站点,请求按预期工作。我正在使用2.7。 from l
TDPL 描述了 assert(false); 语句的行为。此类断言不会从发布版本中删除(与所有其他断言一样),并且实际上会立即停止程序。问题是为什么?为什么会有如此令人困惑的行为?他们可能会添加 h
如何确定文档是否存在于 Meteor 的集合中? 编辑:新代码。 mongodb 有一个 ProductName 的文档:Apples 输入产品是“苹果” var exists = Products.
我想在 R 中做一些相当复杂的事情,但我不确定从哪里开始。 我有一个看起来像这样的数据框: main_val sub_val bit_one bit_two one a 1
我正在尝试编写一个函数 long(S1,S2) 如果 S1 比 S2 长,则该函数应该为真,否则为假。到目前为止,我所拥有的是以下内容: longer(A,nil). longer(nil,B) :-
我想知道我在这里缺少什么我有一个代码可以检查图像是否基于 Canvas 是透明的。 function Trasparent(url, npc, clb) { var img = new Ima
我想在按下按钮时使其他类框架设置可见(false)。 有一个名为 DisplayScore 的类,该类获取 getContentPane().add(new ScoreInfo());来自 Score
我正在使用 TableLayout 和 TableRow 创建 6/6 网格按钮。 private Button myButton; private static final int
这个问题没有实际用途!我之所以问这个只是因为我很好奇! 在C++中,有一种方法可以通过在某处编写#define true false来将true伪造为false,然后在代码中到处的true都将被视为f
我不久前学习 java,所以也许我有一个愚蠢的问题。 我有一张表,我在其中存储了一些信息。我想在此表中检查一些信息的可用性(这将只有一行),如果是 - 从这一行中获取特定列中的信息,如果没有 - 做另
这是一个 JavaScript 问题... 我正在尝试返回完全不区分大小写的匹配项。例如,如果我在输入框中输入 "yo",我希望它返回 true,这在我当前的方法中是这样做的,但它也会返回 true
我认为,我在 JS 中写了一个直接的 if 语句,但它运行不正确。 function printLetter(LetterId) { var studentflag = $("#IsStude
我如何使用 Javascript 执行以下操作? var object function() { return { object: Return true if object
我试图让导航栏在向上滚动时向下滑动,并在单击#menu-bar 时保持固定。但是当我再次单击同一个按钮时,我不知道如何在自动隐藏时将值改回 false,就在我有两个按钮的时候。非常感谢任何帮助! $(
下面的代码 #include using namespace std; int main(){ char greeting[50] = "goodmorning everyone";
我正在使用数据源将数据填充到我的数据 GridView 中。但是,我正在尝试找到一种方法让用户能够隐藏他不想看到的列。 我可以在程序运行之前隐藏和显示列: [Browsable(false)] pub
我是一名优秀的程序员,十分优秀!