Java 创建bean时出错

Java 创建bean时出错,java,spring,javabeans,Java,Spring,Javabeans,我有以下AccountController类 @Controller @RequestMapping("/rest/accounts") public class AccountController { private AccountService accountService; @Autowired public AccountController(AccountService accountService) { this.accountService = accountServic

我有以下AccountController类

@Controller
@RequestMapping("/rest/accounts")
public class AccountController {
private AccountService accountService;

@Autowired
public AccountController(AccountService accountService) {
    this.accountService = accountService;
}
... implemented methods here
} 
AccountService类如下所示

public interface AccountService {
public Account findAccount(BigInteger id);

public Account createAccount(Account data);

public Account deleteAccount(String email);

public Boolean updateAccount(String email,String password);

public List<Account> findAllAccounts();

// public Account deleteAccount();

public Customer createCustomer(String accountId, Customer data);

public List<Customer> findCustomersByAccount(String accountId);

}
公共类AccountServiceImpl实现AccountService{

@Autowired
private AccountRepository accountRepo;

@Autowired
private CustomerRepository custRepo;
..implemented methods here 
}

我的servlet.xml具有以下组件扫描

<context:component-scan base-package="com.sam.spring.web.rest.mvc" />

我在这个设置中做错了什么?

试试这个

试试这个
你在你的上下文中使用
吗?

你在你的上下文中使用
吗?

是的,我是。我把它放在上下文中的标记后面。xmlYes我是。我将它放在context.xml中的标记之后
<context:component-scan base-package="com.sam.spring.web.rest.mvc" />
<context:component-scan base-package="com.sam.spring.web.core.services"></context:component-scan>
<context:component-scan base-package="com.sam.spring.web.core.repositories.jpa"></context:component-scan>
org.springframework.beans.factory.BeanCreationException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountController' defined in file ...

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.sam.spring.web.core.services.AccountService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.