我没有想到的是

我没有想到的是 查看完整档案

填写现居城市  |  填写毕业院校  |  填写所在公司/组织填写个人主网站
编辑
_ | |__ _ _ __ _ | '_ \| | | |/ _` | | |_) | |_| | (_| | |_.__/ \__,_|\__, | |___/ 个人简介什么都没有

个人动态

我没有想到的是 提出了问题 · 2017-04-10

Spring Test 整合 JUnit 4 使用

Spring Test 整合JUnit 单元测试,报org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type

这是代码:

import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.joytime.eticket.reply.model.EshopSobillEvaluate;
import com.joytime.eticket.reply.model.EshopSobillEvaluateId;
import com.joytime.eticket.reply.service.EshopSobillEvaluateService;



@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:/Webapp/WEB-INF/applicationContext.xml")
public class testAdd {
    
    @Resource
    private EshopSobillEvaluateService evaluateService;
    
    @Test
    public void testadd() {
    //ApplicationContext applicationContext = new ClassPathXmlApplicationContext("Webapp/WEB-INF/applicationContext.xml");
    EshopSobillEvaluate es=new EshopSobillEvaluate();
    EshopSobillEvaluateId eid=new EshopSobillEvaluateId();
    eid.setContent("111");
    es.setId(eid);
    evaluateService.saveEvaluate(es);
    }
    
}

这是报错信息:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testAdd': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.joytime.eticket.reply.service.EshopSobillEvaluateService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:321)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:386)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.joytime.eticket.reply.service.EshopSobillEvaluateService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1486)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:518)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:627)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318)
    ... 26 more

关注 4 回答 3

我没有想到的是 回答了问题 · 2017-03-22

SpringMVC+hibernate获取数据报错??

这个用法有错误,hibernate 是对dao层进行操作,service是操作业务逻辑代码,controller是空气器,这是要明确分工,下面是个简单的小demo

//新建UserDao
package com.purchase.dao;
import com.purchase.domain.User;

public interface UserDao {
    public void addUser(User user);
}



//新建实现类UserDaoImpl
public class UserDaoImpl implements UserDao{

    private SessionFactory sessionFactory;  
    public void setSessionFactory(SessionFactory sessionFactory) {  
        this.sessionFactory = sessionFactory;  
    }  
  
    @Override   
    public void addUser(User user) {//添加用户  
        sessionFactory.getCurrentSession().save(user);  
    }  
}

//新建service类
public interface UserService {  
    public void addUser(User user);  
    }
    
//新建service实现类
public class UserServiceImpl implements UserService {
    public UserDao userDao;
    
    @Override  
    public void addUser(User user) {  
        userDao = new UserDaoImpl();
        userDao.addUser(user);  
    }  
    }

    
//新建controller控制类
@Controller  
@RequestMapping("/user")  
public class UserController {  
    @Resource(name="userService")// 获取spring配置文件中bean的id为userService的,并注入   
    private UserService userService;     
    
    @RequestMapping("/addUser")// 请求url地址映射,类似Struts的action-mapping   
    public String addUser(User user){    
        userService.addUser(user);  
        return "redirect:/user/success";  
    } 
    }

关注 3 回答 3

我没有想到的是 关注了问题 · 2016-12-12

推荐个前端数据表格插件

有没有好用的基于jquery的数据表格插件,功能包含分页,全选一些基本功能即可,无需太复杂.

关注 9 回答 10

我没有想到的是 回答了问题 · 2016-12-12

推荐个前端数据表格插件

关注 9 回答 10

我没有想到的是 关注了问题 · 2016-12-12

移动开发怎么样 才能既可以发表文字 又可以上传图片??

移动开发怎么样 才能既可以发表文字 又可以上传图片??

就是像微信发朋友圈那样 既可以发图片 又可以发文字 。。。

现在 用的是 input type = file 这种模式 点击该input的时候 只能选择图片 文字 该怎么办 ??

关注 5 回答 5

我没有想到的是 回答了问题 · 2016-12-12

移动开发怎么样 才能既可以发表文字 又可以上传图片??

同上 使用移动端富文本编辑器

关注 5 回答 5

认证与成就

  • 获得 2 次点赞
  • 获得 4 枚徽章 获得 0 枚金徽章, 获得 1 枚银徽章, 获得 3 枚铜徽章

擅长技能
编辑

(゚∀゚ )
暂时没有

开源项目 & 著作
编辑

(゚∀゚ )
暂时没有

注册于 2016-12-02
个人主页被 466 人浏览