我正在检查一些Spring Integration with GCP pub sub,并且我已经克隆了他们的示例项目。我在IDE中收到一个警告/错误,我正在努力理解它。
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;
}
}我有以下错误
Could not autowire. No beans of 'PubSubPersonGateway' type found. 谁能解释一下为什么我会收到这个错误/警告,以及这是不是我需要关注的问题?仅供参考,项目将正确编译和运行
发布于 2021-09-07 16:07:59
这只是一个IDE检查问题,仅此而已。该PubSubPersonGateway是一个特殊的@MessagingGateway bean,它不被集成开发环境所理解。也许更好的做法是针对该IDE提出改进建议,让他们知道Spring Integration检查应该得到改进。
https://stackoverflow.com/questions/69080981
复制相似问题