81,095
社区成员
发帖
与我相关
我的任务
分享
Error creating bean with name 'com.spring.test.UserServiceTest': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.spring.service.IUserService com.spring.test.UserServiceTest.userService;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.spring.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
(locations={"classpath*:config/spring/springmvc.xml","classpath*:config/spring/applicationContext-*.xml","classpath*:config/mybatis/sqlMapConfig.xml"})
public class BaseJunit4Test {
}
public class UserServiceTest extends BaseJunit4Test {
private static Logger logger = Logger.getLogger(UserServiceTest.class);
long startruntime = 0;
long endruntime = 0;
@Before
public void before(){
startruntime=System.currentTimeMillis(); //获取开始时间
}
@After
public void after(){
endruntime=System.currentTimeMillis(); //获取开始时间
logger.info("此次方法运行时间: "+(endruntime-startruntime)+"ms");
}
@Autowired
private IUserService userService;
@Test
public void loginTest() throws Exception {
User user = userService.login("admin", "admin", null);
logger.info(user.toString());
}
}
@Autowired
private IUserService userService;
@Test
public void loginTest() throws Exception {
logger.info("test");
}