首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

Spring MVCjavascript:void(0); +Hibernate 关于spring注入的有关问题

2013-11-01 
Spring MVCjavascript:void(0) +Hibernate关于spring注入的问题哪位遇到过类似的错误,怎么解决的?希望一

Spring MVCjavascript:void(0); +Hibernate 关于spring注入的问题
哪位遇到过类似的错误,怎么解决的?希望一起分享、、

异常信息:
Spring MVCjavascript:void(0); +Hibernate  关于spring注入的有关问题

Spring MVCjavascript:void(0); +Hibernate  关于spring注入的有关问题

Spring MVCjavascript:void(0); +Hibernate  关于spring注入的有关问题

相关的代码:
GivingRecordBusinessImpl.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.magus.farmgameclient.business.impl;

import com.magus.farmgameclient.business.BaseBusiness;
import com.magus.farmgameclient.constants.G;
import com.magus.farmgameclient.formbeans.TGameUserFormBean;
import com.magus.farmgameclient.models.TGameGivingRecord;
import com.magus.farmgameclient.models.TGameUser;
import com.magus.farmgameclient.models.TGameUserBag;
import com.magus.farmgameclient.services.TGameGivingRecordService;
import com.magus.farmgameclient.services.TGameUserBagService;
import com.magus.farmgameclient.services.TGameUserService;
import com.magus.shframework.helpers.JsonHelper;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

/**
 *
 * @author gaoxiang
 */
@Component("givingRecordBusinessImpl")
public class GivingRecordBusinessImpl implements BaseBusiness{
    private static final Log log = LogFactory.getLog(GivingRecordBusinessImpl.class);

    @Resource(name = "tGameUserServiceImpl")
    private TGameUserService tGameUserService;
    @Resource(name = "tGameUserBagServiceImpl")
    private TGameUserBagService tGameUserBagService;
    @Resource(name = "tGameGivingRecordServiceImpl")
    private TGameGivingRecordService tGameGivingRecordService;
    
    
    @Override
    public String process(HttpServletRequest request, TGameUserFormBean userFormBean) {
         
        String jsonString = "";
        try{
            //判断用户是否存在
             TGameUser user = tGameUserService.findById(TGameUser.class, Long.parseLong(userFormBean.getUserId()));
             if(user==null){
              jsonString = JsonHelper.setRespCodeAndRespMsg(G.RespCodeAndMsg.USER_NOT_EXISTS_CODE,
                        G.RespCodeAndMsg.USER_NOT_EXISTS_MSG);
                return jsonString;
             }

    
    
           
         
            //处理分享到人人网的赠送逻辑
            if(G.ActionId.SHARE_RENREN.equals(userFormBean.getActionId())){
              List<TGameGivingRecord> givingrecordlist =  tGameGivingRecordService.findGivingrecordOnTodayByType(user.getUserId(), G.ActionId.SHARE_RENREN);
              if( givingrecordlist!=null){
              jsonString = JsonHelper.setRespCodeAndRespMsg(G.RespCodeAndMsg.USER_REPEAT_SHARE_CODE,
                        G.RespCodeAndMsg.USER_REPEAT_SHARE_MSG);
              return jsonString;
              }
               tGameUserBagService.givePropsBySys(G.ConstantsKey.SHARE_RENREN_AWARD, user.getUserId()); 
            }
        
            //处理分享到新浪微博的赠送逻辑
            if(G.ActionId.SHARE_WEIBO.equals(userFormBean.getActionId())){
              List<TGameGivingRecord> givingrecordlist =  tGameGivingRecordService.findGivingrecordOnTodayByType(user.getUserId(), G.ActionId.SHARE_WEIBO);


              if( givingrecordlist!=null){
              jsonString = JsonHelper.setRespCodeAndRespMsg(G.RespCodeAndMsg.USER_REPEAT_SHARE_CODE,
                        G.RespCodeAndMsg.USER_REPEAT_SHARE_MSG);
              return jsonString;
              }
               tGameUserBagService.givePropsBySys(G.ConstantsKey.SHARE_WEIBO_AWARD, user.getUserId()); 
            } 
        
            //处理分享到微信的赠送逻辑
            if(G.ActionId.SHARE_WEIXIN.equals(userFormBean.getActionId())){
              List<TGameGivingRecord> givingrecordlist =  tGameGivingRecordService.findGivingrecordOnTodayByType(user.getUserId(), G.ActionId.SHARE_WEIXIN);
              if( givingrecordlist!=null){
              jsonString = JsonHelper.setRespCodeAndRespMsg(G.RespCodeAndMsg.USER_REPEAT_SHARE_CODE,
                        G.RespCodeAndMsg.USER_REPEAT_SHARE_MSG);
              return jsonString;
              }
               tGameUserBagService.givePropsBySys(G.ConstantsKey.SHARE_WEIXIN_AWARD, user.getUserId()); 
            } 
    
            //处理第一次在线支付、并支付300赠送的逻辑
            if(G.ActionId.FIRST_PAY_300.equals(userFormBean.getActionId())){
              List<TGameGivingRecord> givingrecordlist =  tGameGivingRecordService.findGivingrecordOnTodayByType(user.getUserId(), G.ActionId.FIRST_PAY_300);
              if( givingrecordlist!=null){
              jsonString = JsonHelper.setRespCodeAndRespMsg(G.RespCodeAndMsg.USER_REPEAT_PAY_CODE,
                        G.RespCodeAndMsg.USER_REPEAT_PAY_MSG);
              return jsonString;
              }
               tGameUserBagService.givePropsBySys(G.ConstantsKey.FIRST_PAY_300_AWARD, user.getUserId()); 
            }     
            
            //处理第一次在线支付、并支付500的逻辑
              if(G.ActionId.FIRST_PAY_500.equals(userFormBean.getActionId())){
              List<TGameGivingRecord> givingrecordlist =  tGameGivingRecordService.findGivingrecordOnTodayByType(user.getUserId(), G.ActionId.FIRST_PAY_500);
              if( givingrecordlist!=null){
              jsonString = JsonHelper.setRespCodeAndRespMsg(G.RespCodeAndMsg.USER_REPEAT_PAY_CODE,
                        G.RespCodeAndMsg.USER_REPEAT_PAY_MSG);
              return jsonString;
              }
               tGameUserBagService.givePropsBySys(G.ConstantsKey.FIRST_PAY_500_AWARD, user.getUserId()); 
            }   
              
            //在线下单、并在线支付赠送的逻辑
              if(G.ActionId.FIRST_PAY.equals(userFormBean.getActionId())){
              List<TGameGivingRecord> givingrecordlist =  tGameGivingRecordService.findGivingrecordOnTodayByType(user.getUserId(), G.ActionId.FIRST_PAY);


              if( givingrecordlist!=null){
              jsonString = JsonHelper.setRespCodeAndRespMsg(G.RespCodeAndMsg.USER_REPEAT_PAY_CODE,
                        G.RespCodeAndMsg.USER_REPEAT_PAY_MSG);
              return jsonString;
              }
               tGameUserBagService.givePropsBySys(G.ConstantsKey.FIRST_PAY_AWARD, user.getUserId()); 
            }   
              
              
             List<TGameUserBag> bagList = tGameUserBagService.findByProperty(TGameUserBag.class, "userId", user.getUserId());
             String[] paramsName = {"propsList"};
             Object[] paramsValue = {bagList};
             
             jsonString = JsonHelper.toJson(G.RespCodeAndMsg.SUCCESS_CODE, G.RespCodeAndMsg.SUCCESS_MSG, paramsName, paramsValue);
             
        }catch(Exception ex){
        log.error("服务器异常!", ex);
            jsonString = JsonHelper.setRespCodeAndRespMsg(G.RespCodeAndMsg.SERVER_EXCEPTION_CODE, G.RespCodeAndMsg.SERVER_EXCEPTION_MSG);
        }
        
        return jsonString;
        
    }
    
}



TGameGivingRecordServiceImpl
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.magus.farmgameclient.services.impl;

import com.magus.farmgameclient.services.TGameGivingRecordService;
import com.magus.farmgameclient.daos.TGameGivingRecordDao;
import com.magus.farmgameclient.daos.TGameUserBagDao;
import com.magus.farmgameclient.models.TGameGivingRecord;
import com.magus.farmgameclient.services.TGameUserBagService;
import com.magus.shframework.helpers.CommonHelper;
import com.magus.shframework.services.impl.BaseServiceImpl;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 *
 * @author gaoxiang
 */
@Service("tGameGivingRecordServiceImpl")
public class TGameGivingRecordServiceImpl extends BaseServiceImpl<TGameGivingRecord, Long> implements TGameGivingRecordService {
    @Resource(name="TGameGivingRecordDaoImpl")
    private TGameGivingRecordDao tGameGivingRecordDao;
    @Resource(name = "tGameUserBagDaoImpl")
    private TGameUserBagDao tGameUserBagDao;
    @Resource(name = "tGameUserBagServiceImpl")
    private TGameUserBagService tGameUserBagService;
    
    /*
     * 查找用户指定操作的赠送记录
     * @param userId 用户id
     * @param actionId 操作类型(分享(QQ空间/微博/人人/微信)、在线支付、第一次在线支付并达到一定的额度),如果为空就是所有操作
     */
    @Override
    public List<TGameGivingRecord> findGivingrecordOnTodayByType(Long userId,String actionId){
         List<TGameGivingRecord> givingrecordlist = null;
         Date curDate = new Date();
        Timestamp startTimestampToday = new Timestamp (CommonHelper.calculatorStartTimeOnDay(curDate));
        String hql = "from TGameGivingrecord gr Where gr.userId=:userId and gr.actionId=:actionId"+
                "and gr.createTime>=:startTimestampToday and op.createTime <= current_timestamp order by op.createTime desc";
        Map<String, Object> paramsMap = new HashMap<String, Object>();


        paramsMap.put("userId", userId);
        paramsMap.put("startTimestampToday", startTimestampToday);
        if(actionId==null){
           hql = "rom TGameGivingrecord gr Where gr.userId=:userId "+
                   "and gr.createTime>=:startTimestampToday and op.createTime <= current_timestamp order by op.createTime desc";
        }else {
            paramsMap.put("actionId", actionId);
        }
        givingrecordlist = tGameGivingRecordDao.find(hql, paramsMap);
        return givingrecordlist;
    }
}



spring??java?
[解决办法]
引用:
TGameGivingRecordDaoImpl 这个类发出来。
+1
[解决办法]
注入的时候得保证注入的名称一致,@Repository("tGameGivingRecordDaoImpl")命名是小写,你在其他地方引用的也得是小写。No bean named 'TGameGivingRecordDaoImpl' is defined明显这里提示的是大写T

热点排行