2016-02-10 64 views
0

我已在AccountController類以下錯誤創建豆

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

@Autowired 
public AccountController(AccountService accountService) { 
    this.accountService = accountService; 
} 
... implemented methods here 
} 

的帳戶服務類,如下

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類是如下

@Service 

公共類AccountServiceImpl實現帳戶服務{

@Autowired 
private AccountRepository accountRepo; 

@Autowired 
private CustomerRepository custRepo; 
..implemented methods here 

}

我servlet.xml中具有以下組件掃描

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

的/src/resource/context.xml具有以下

<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. 

我在這個設置中做了什麼錯誤?

回答

1

試試這個<context:component-scan base-package="com.sam.spring.web.rest.mvc, com.sam.spring.web.core.services, com.sam.spring.web.core.repositories.jpa" />

1

是否使用在烏拉圭回合背景下<context:annotation-config/>

+0

是的,我。我將它放在context.xml中的標記之後 – MindBrain

相關問題