有人来帮忙看看这个有没有问题

YoungTreeTree 2017-02-26 04:25:46
不会配用工厂方法生成的javabean 然后我在service里面套了一层service 瞎写的 帮忙看看能不能这么用 谢谢


public class ShopAction extends BaseAction{
@Resource
private TradeService tradeService;
private BaseJson queryJson =new BaseJson();
public BaseJson getQueryJson() {
return queryJson;
}
public void setQueryJson(BaseJson queryJson) {
this.queryJson = queryJson;
}

public TradeService getTradeService() {
return tradeService;
}
public void setTradeService(TradeService tradeService) {
this.tradeService = tradeService;
}
/*测试*/
public String trade(){
System.out.println("ShopAction");
return SUCCESS;
}
}

package yang.service;



import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alipay.demo.trade.config.Configs;
import com.alipay.demo.trade.service.AlipayTradeService;
import com.alipay.demo.trade.service.impl.AlipayTradeWithHBServiceImpl;

import yang.other.BaseDAO;




@Service("TradeService")
public class TradeService {

private static AlipayTradeService tradeWithHBService;
static {
/** 一定要在创建AlipayTradeService之前调用Configs.init()设置默认参数
* Configs会读取classpath下的zfbinfo.properties文件配置信息,如果找不到该文件则确认该文件是否在classpath目录
*/
Configs.init("zfbinfo.properties");

/** 使用Configs提供的默认参数
* AlipayTradeService可以使用单例或者为静态成员对象,不需要反复new
*/
// tradeService = new AlipayTradeServiceImpl.ClientBuilder().build();

// 支付宝当面付2.0服务(集成了交易保障接口逻辑)
tradeWithHBService = new AlipayTradeWithHBServiceImpl.ClientBuilder().build();

}

@Resource
protected BaseDAO baseDAO;
}


...全文
239 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
QuinnNorris 2018-07-17
  • 打赏
  • 举报
回复
static块仅加载一次,service是无状态的,不区分多个线程。
YoungTreeTree 2017-02-26
  • 打赏
  • 举报
回复
能不能符合注释里面支付宝的要求啊

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧