首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Integration Pub子项目示例项目“无法自动布线。找不到'PubSubTemplate‘类型的bean。”

Spring Integration Pub子项目示例项目“无法自动布线。找不到'PubSubTemplate‘类型的bean。”
EN

Stack Overflow用户
提问于 2021-09-06 23:10:49
回答 1查看 58关注 0票数 0

我正在检查一些Spring Integration with GCP pub sub,并且我已经克隆了他们的示例项目。我在IDE中收到一个警告/错误,我正在努力理解它。

基本上在这个类https://github.com/spring-cloud/spring-cloud-gcp/blob/6c95a16f7e6ad95404b4f992b5f46340e831e5cb/spring-cloud-gcp-samples/spring-cloud-gcp-integration-pubsub-json-sample/src/main/java/com/example/WebController.java#L47

代码语言:javascript
复制
package com.example;

import java.util.ArrayList;
import java.util.List;

import com.example.SenderConfiguration.PubSubPersonGateway;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.view.RedirectView;

/**
 * Provides REST endpoint allowing you to send JSON payloads to a sample Pub/Sub topic for
 * demo.
 *
 * @author Daniel Zou
 */
@RestController
public class WebController {

    private final PubSubPersonGateway pubSubPersonGateway;

    @Autowired
    @Qualifier("ProcessedPersonsList")
    private ArrayList<Person> processedPersonsList;

    public WebController(PubSubPersonGateway pubSubPersonGateway, SenderConfiguration.PubSubProjectGateway pubSubProjectGateway ) {
        this.pubSubPersonGateway = pubSubPersonGateway;
    }

    @PostMapping("/createPerson")
    public RedirectView createUser(@RequestParam("name") String name, @RequestParam("age") int age) {
        Person person = new Person(name, age);
        this.pubSubPersonGateway.sendPersonToPubSub(person);
        return new RedirectView("/");
    }

    @GetMapping("/listPersons")
    public List<Person> listPersons() {
        return this.processedPersonsList;
    }
}

我有以下错误

代码语言:javascript
复制
Could not autowire. No beans of 'PubSubPersonGateway' type found. 

谁能解释一下为什么我会收到这个错误/警告,以及这是不是我需要关注的问题?仅供参考,项目将正确编译和运行

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-07 16:07:59

这只是一个IDE检查问题,仅此而已。该PubSubPersonGateway是一个特殊的@MessagingGateway bean,它不被集成开发环境所理解。也许更好的做法是针对该IDE提出改进建议,让他们知道Spring Integration检查应该得到改进。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69080981

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档