第一步:将demo中的zbbinfo.properties拷贝到resources里面
第二步:将demo的lib下的4个sdk拷贝到项目的的WEB-INF下的lib下
第三步:通过pom.xml配置依赖的jar包 注:和官方的demo的版本保持一致(不用通过拷贝lib下面的jar包)
第四步:将main和DemoHbRunner这2个类拷贝过来,然后点击 file-------project structure------modules-----+----JARs or ..将拷贝到WEB-INF 的lib下的jar包加载到本机里面。变红就会消失
第五步:在pom.xml文件里面配置插件(解决发布到服务器后,找不到alipay那4个类了)就是如何把本地jar包发布到服务器上就需要这个插件
<!-- maven的核心插件之-complier插件默认只支持编译Java 1.4,因此需要加上支持高版本jre的配置,在pom.xml里面加上 增加编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
</plugins>
第六步:启动main函数,出现支付宝预下单成功,说明我们集承到项目的配置是成功的。
-------------------------------------------------------------------------
第七步:写支付宝的3个重要的接口(支付宝支付方法、支付宝回调方法、查询订单支付状态的方法)
public ServerResponse pay(Long orderNo, Integer userId, String path) {
//用map来承载这个对象
Map<String, String> resultMap = Maps.newHashMap();
Order order = orderMapper.selectByUserIdAndOrderNo(userId, orderNo);
if (order == null) {
return ServerResponse.createByErrorMessage("用户没有该订单");
}
//***********************************************