背景
我使用的是支付宝开放平台的电脑支付接口,当我支付完成之后支付宝会回调我的return_url
,然后回调的时候没有回调成功,中间出现了这个错误,具体错误如下:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Jul 02 13:11:03 CST 2020
There was an unexpected error (type=Internal Server Error, status=500).
com/alipay/api/internal/util/AlipaySignature
解决办法
我去网上搜索了com/alipay/api/internal/util/AlipaySignature
几乎没有相同的例子,但是别人都在说支付宝的事情,我突然想到,会不会是支付宝jar包引起的问题,之前我就遇到类似的问题,都是打war包之后支付宝jar包没有打进去,点击我去看类似问题,不过那个是连接支付宝接口的,这个是支付宝回调我的,不太一样,但是都需要支付宝jar包,然后我就去tomcat安装目录下面的webapps下面的WEB-INF下面的lib中添加了支付宝jar包,然后重启tomcat,最后就可以正常访问了
解惑
当前时间是2023-07-02,这篇文章是2年之前写的,当时只知道去解决问题,但是不知道产生问题的原因是什么,也就是没有抓住问题的本质,最近在看《Maven实战》这本书,发现了原因,所以来解答一下两年前自己留下的坑
由于上述依赖的scope属性是system(系统依赖范围),该依赖范围只在编译、测试时有效,但是在运行时无效,详细解释请看:《Maven实战》
P64 表5-1“依赖范围与classpath的关系”
对于springboot项目来说,如果在打包时想要将scope属性为system的jar包打包,那就需要在pom.xml中添加以下配置:
注意:以下为pom.xml文件中的配置
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- start 允许引入本地jar包 -->
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
<!-- end 允许引入本地jar包 -->
</plugin>
……
</plugins>
……
</build>