首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Boot与Spring 3的依赖关系

Spring Boot与Spring 3的依赖关系
EN

Stack Overflow用户
提问于 2018-07-13 13:20:18
回答 1查看 48关注 0票数 0

我有一个依赖于Spring 3的项目,我正在最新的spring boot项目中使用它

我遇到了自动布线的问题,我的Spring3项目有一个网关接口(IAccountGateway)

我正面临着这样的问题

代码语言:javascript
复制
Description:<br>
 <br>Field iAccountGateway in
 com.rvi.service.common.impl.RegistrationService required a bean of type
 'com.rvi.jms.gateway.IAccountGateway' that could not be found. <br><br>Action:<br>
Consider defining a bean of type 'com.rvi.jms.gateway.IAccountGateway'
in your configuration.

当我把debug放到我的spring项目中时,我得到了类似下面的日志

代码语言:javascript
复制
Registered injected element on class <br><br>
[com.rvi.service.common.impl.RegistrationService]:
AutowiredFieldElement for private com.rvi.jms.gateway.IAccountGateway
com.rvi.service.common.impl.RegistrationService.iAccountGateway
EN

回答 1

Stack Overflow用户

发布于 2018-07-13 21:49:53

好吧,如果IAccountGateway是一个接口,那么您需要实现它并使用@Component注释将其定义为Spring Bean (还有一些other注释具有类似的效果)。

IAccountGateway.java

代码语言:javascript
复制
public interface IAccountGateway {

    // ..

}

AccountGatewayImpl.java ( IAccountGateway实现)

代码语言:javascript
复制
import org.springframework.stereotype.Component;

@Component
public class AccountGatewayImpl implements IAccountGateway {

    // ..

}

自动生成字段的

代码语言:javascript
复制
import org.springframework.beans.factory.annotation.Autowired;

public class Clazz {

    @Autowired
    IAccountGateway iAccountGateway;

    // ..
}

请参阅Spring Boot Reference on Spring Beans and Dependency Injection

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

https://stackoverflow.com/questions/51318114

复制
相关文章

相似问题

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