У меня есть проблема с Spring и OpenFeign, в которой я думаю, что вы можете мне помочь. = "lang-xml prettyprint-override">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
xx.yyy
component
1.0.0
component
1.8
3.1.1
3.6.7
Greenwich.SR4
org.springframework.boot
spring-boot-starter-parent
2.1.10.RELEASE
org.springframework.boot
spring-boot-starter-actuator
org.springframework.boot
spring-boot-starter-amqp
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-tomcat
org.springframework.boot
spring-boot-starter-jetty
org.springframework.cloud
spring-cloud-starter-config
org.springframework.cloud
spring-cloud-starter-openfeign
......
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
......
< /code>
Я объявил в основном классе.@SpringBootApplication(scanBasePackages = {"xx.yyy", "xx.yyy.rest.client"}, exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
@EnableAsync
@Import({P2OrchestratorApplicationConfig.class})
public class P2OrchestratorApplication {
public static void main(String[] args) {
SpringApplication.run(P2OrchestratorApplication.class, args);
}
}
< /code>
У меня есть пользовательский класс конфигурации Forign: < /p>
@Configuration
@EnableFeignClients()
@ImportAutoConfiguration({FeignAutoConfiguration.class})
public class FeignConfig {
@Bean
public OkHttpClient client() {
return new OkHttpClient();
}
@Bean
public Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
}
@Bean
public Contract feignContract() {
return new feign.Contract.Default();
}
}
< /code>
У меня есть клиент Open Fainte: < /p>
@FeignClient(name="legacyClient", value = "legacyClient", url = "${uri.microservice.legacy}", configuration = FeignConfig.class)
public interface LegacyClient {
@PatchMapping(value = "/legacy/xxx/cleanLine/{authorizationCode}", produces = { MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity cleanLine(@PathVariable("authorizationCode") Long authorizationCode, @RequestParam(required = true) Long lineNumber);
}
< /code>
и, наконец, компонент, в котором мне нужно использовать этот клиент: < /p>
@Log4j
@Component("p2ProcessAlgorithm")
public class P2ProcessAlgorithm {
@Autowired
@Qualifier("legacyClient")
private LegacyClient legacyClient;
public final void process(){
Long authorizationCode = 123L;
Long lineNumber = 1L;
Boolean isClean= this.legacClient.cleanLine(authorizationCode, lineNumber);
......
}
< /code>
Но приложение дает мне следующее сообщение: < /p>
***************************
APPLICATION FAILED TO START
***************************
Description:
Field legacyClient in xxx.yyy.p2.structure.P2ProcessAlgorithm required a bean of type 'xxx.yyy.rest.client.LegacyClient' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
- @org.springframework.beans.factory.annotation.Qualifier(value=p2AsyncOrchestratorService)
Action:
Consider defining a bean of type 'xxx.yyy.rest.client.LegacyClient' in your configuration.
< /code>
Я попробовал несколько конфигураций, но я не могу заставить клиента OpenFeign быть распознанным бобом в классе P2ProcessAlgorithm. < /p>
У вас есть Есть идея?
Заранее
Подробнее здесь: https://stackoverflow.com/questions/590 ... t-be-found
OpenFeign + Spring Cloud: поле требуется боб типа, который нельзя найти ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Openfeign + Spring Cloud: поле требовало bean-компонента типа, который не удалось найти.
Anonymous » » в форуме JAVA - 0 Ответы
- 35 Просмотры
-
Последнее сообщение Anonymous
-