问题描述:
java.lang.ClassCastException: class sun.net.www.protocol.http.HttpURLConnection cannot be cast to class javax.net.ssl.HttpsURLConnection (sun.net.www.protocol.http.HttpURLConnection and javax.net.ssl.HttpsURLConnection are in module java.base of loader 'bootstrap')
问题分析:
1、url的协议为http,但是HttpsURLConnection只能转化协议为https的url。
解决办法:协议为https的url用HttpsURLConnection接收,协议为http的url用HttpURLConnection接收。