Spring Integration Pub 子示例项目"Could not autowire. No beans of 'PubSubTemplate' type found."
Spring Integration Pub sub sample project "Could not autowire. No beans of 'PubSubTemplate' type found."
我正在检查一些 Spring 与 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.
有人可以解释为什么我会收到此错误/警告吗?是否需要我关注?仅供参考,该项目将编译并 运行 正确
这只是一个 IDE 检查问题,仅此而已。 PubSubPersonGateway
是一个特殊的 @MessagingGateway
bean,IDE 无法理解。可能最好针对 IDE 提出改进票,让他们知道 Spring 集成检查应该改进。
我正在检查一些 Spring 与 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.
有人可以解释为什么我会收到此错误/警告吗?是否需要我关注?仅供参考,该项目将编译并 运行 正确
这只是一个 IDE 检查问题,仅此而已。 PubSubPersonGateway
是一个特殊的 @MessagingGateway
bean,IDE 无法理解。可能最好针对 IDE 提出改进票,让他们知道 Spring 集成检查应该改进。