utf-8

#utf-8#

已有0人关注此标签

内容分类

支付宝不好用啊

支付已经成功,支付宝账户已经收到款,但是查询订单,查询结果是订单不存在

支付参数如下 { "app_id":"2017092608938730", "version":"1.0", "format":"JSON", "sign_type":"RSA2", "method":"alipay.trade.query", "timestamp":"2019-06-19 13:40:42", "alipay_sdk":"alipay-sdk-php-20161101", "notify_url":"http://www.xjsmyy.com:6250/v1/alipay/page/notify", "charset":"UTF-8", "biz_content":"{\"out_trade_no\":\"L20190619A3H75W\"}", "sign":"h4YGryVFIYw0IoL/2qexN/e/juQN7IHAQxZE80mO1AtRmrOE3CzCTBHabaTfFWIl3YzPIhKQzfmcpXLqBOtBuCoL/cZ4K4uN13HKr8QT8ouMHn0aA1bnFhsW5m2w1GaPtbASzcRrpH/CR9WdxBPdSY5HB8qFc0RVk5H+jsRTpjwoFyEdbeymss9tTj4tguZ+h2S/4dZ6gQ19Fp+HGbhu4MKi13lzOYKx/RXkYOgPHgTBsoG0xWMb504Bwr5lpl6efTrXp/CrpORkTFvjlykE+N8cf7SFb933duG2rlIMDhcK+IQjLS4zEc1P7Yjg6V0FWrJl1ZP02X7uze1ydr2MdA==" } 回调结果如下 {"alipay_trade_query_response":{"code":"40004","msg":"Business Failed","sub_code":"ACQ.TRADE_NOT_EXIST","sub_msg":"交易不存在","buyer_pay_amount":"0.00","invoice_amount":"0.00","out_trade_no":"L20190619A3H75W","point_amount":"0.00","receipt_amount":"0.00"},"sign":"jRe1x/QvC65n5Zlk2Awuh9Yuhc+cZ24ea7ZCcjnUJPf93SsETMZlq/8704J+JFZQ84YH/r68e8LlclqjW5msIHcnMg7qITp+QMD3rPx5bCeQ5yDAkfoWVNpqbvswipvTM37Wx3tLS9Xhtx/Uvs4M4DO+Oikjgc5q6tIFUtxL0EZrgRcqFXP1Mui8H0wVN5iG9fQNvEH1YTZOUXMZkgy+dr5CZQkDeLp/S2d8bfPC7QP7wPPH3NsbUYkKa17tdfRncU0A+BIeiBc9gSoljGiY7ozhKe5gmQ9QgS6ol9BchBah/NOIz8FU6SNDSEKhxcBJmXQqo1UlSLySYZ/DbitwWw=="} 以下是收款截图

小六码奴

【精品问答集锦】Python热门问题

Python字符串比较最小/最大strhttps://yq.aliyun.com/ask/495067如何在python中组合多个列https://yq.aliyun.com/ask/495039在实例化类时动态选择继承?https://yq.aliyun.com/ask/495068Python使用集成绘制函数https://yq.aliyun.com/ask/495091pandas- 在非唯一日期合并两个df(外部联接)https://yq.aliyun.com/ask/495089使用Python进行地理编码 - 从公司名称获取地址https://yq.aliyun.com/ask/495086使用Command设计模式消除重复代码https://yq.aliyun.com/ask/495085在新列中添加唯一标识符,直到另一列满足条件https://yq.aliyun.com/ask/495083使用tensorflow用对象检测代码无法看到结果https://yq.aliyun.com/ask/495080以编程方式在(I)python中制作和保存绘图而不先在屏幕上渲染它们https://yq.aliyun.com/ask/495076使用python从JSON刮取Web数据https://yq.aliyun.com/ask/495073如何在Airflow中将参数传递给PythonOperatorhttps://yq.aliyun.com/ask/495070如何使用python复制现有的csv文件?https://yq.aliyun.com/ask/495069无法创建文件notepad txt utf-8https://yq.aliyun.com/ask/495113如何在python中调试被忽略的异常https://yq.aliyun.com/ask/495112在数据框中查找值并在相应列中交叉引用值https://yq.aliyun.com/ask/495109Python:如何检查两个字符串的匹配字符数?https://yq.aliyun.com/ask/495106 以下问题已有400+用户浏览过但至今还未有人回答,你愿意来挑战下吗? 请教云效自定义构建环境的用法https://yq.aliyun.com/ask/497746python 使用sha256加密时,返回的值和java的不一样 https://yq.aliyun.com/ask/497427?请教下大家,Sublime包管理器无法访问外网安装,想请教下大家如何设置成国内的代理,网上的教程实在是太模糊了~https://yq.aliyun.com/ask/497417如何下载URL数据集https://yq.aliyun.com/ask/497399 python SDK连接不上ecshttps://yq.aliyun.com/ask/496441 技术交流群 【Python技术进阶】 群福利:群内每周进行群直播技术分享及问答

bug_developer

阿里云ECS学生服务器上tomcat与MySQL的连接

这是一个毕业设计项目,我在tomcat中使用servlet去读写同一台ecs服务器上的数据库MySQL 。我使用了tomcat内置的DBCP连接池,在项目的META-INF下配置context.xml配置文件,然后在WEB-INF下的web.xml中进行了配置。context.xml的配置如下:<?xml version="1.0" encoding="UTF-8"?> <Resource name="jdbc/huoyundataSource" auth="Container" type="javax.sql.DataSource" username="root" password="856368" maxIdle="30" maxWaitMillis="1000" maxTotal="100" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/huoyundatabase?useServerPrepStmts=true&cachePrepStmts=true" /> web.xml的配置如下: <?xml version="1.0" encoding="UTF-8"?> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1" metadata-complete="true"> Tomcat Test <description>DB Connection</description> <res-ref-name>jdbc/huoyundataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> 然后读写数据库的servlet代码如下: package myservlet; import java.io.IOException;import java.io.PrintWriter;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.Statement; import javax.naming.Context;import javax.naming.InitialContext;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.sql.DataSource; /** Servlet implementation class orderInServletTest*/ @WebServlet("/orderInServletTest")public class orderInServletTest extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public orderInServletTest() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); try { Context ctx=new InitialContext(); DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/huoyundataSource"); Connection con=ds.getConnection(); String sql="insert into ordertest(USERID,USERPHONE,FIRSTADDR)values(?,?,?)"; PreparedStatement sta = (PreparedStatement)con.prepareStatement(sql); sta.setString(1, "chen"); sta.setString(2, "15980590666"); sta.setString(3, "zhenzhou"); sta.executeUpdate(sql); sta.close(); con.close(); } catch (Exception e) { } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } tomcat使用的版本为9.0,MySQL用的是8.0的版本,servlet可以通过外网正常的访问到,但就是无法将数据插入到MySQL数据库中。 请问,这是哪里可能出现了问题?

游客pdvlbctrwqtt2

使用函数计算调用表格存储一直time out

新手第一次用阿里云的产品。在函数计算写代码获取表格存储的数据,执行日志一直显示timeout,函数执行状态函数执行失败(UnhandledInvocationError)。 函数计算里的代码: -- coding: utf-8 -- import datetimefrom tablestore import * INSTANCE_NAME = 'WLQC2019'REGION = 'cn-shanghai'ENDPOINT = 'https://%s.%s.ots-internal.aliyuncs.com'%(INSTANCE_NAME, REGION)TABLENAME = 'T_User' def get_ots_client(context): creds = context.credentials client = OTSClient(ENDPOINT, creds.accessKeyId, creds.accessKeySecret, INSTANCE_NAME, sts_token = creds.securityToken) return client def handler(event, context): CardID = "AB45TG7HT3" primary_key = [('CardID',CardID)] columns_to_get = [] client = get_ots_client(context) now = datetime.datetime.now().strftime('%Y%m%d%H%M%S') cond = CompositeColumnCondition(LogicalOperator.AND) cond.add_sub_condition(SingleColumnCondition("StartTime", now, ComparatorType.LESS_EQUAL )) cond.add_sub_condition(SingleColumnCondition("EndTime", now, ComparatorType.GREATER_EQUAL )) consumed, return_row, next_token = client.get_row(TABLENAME, primary_key, columns_to_get) return return_row.primary_key 执行日志bject at 0x7f830a18cd10>, 'Connection to wlqc2019.cn-shanghai.ots-internal.aliyuncs.com timed out. (connect timeout=50)')': /GetRow

强心剂

idea配置spring-boot,创建的一些依赖包无法引用

pom配置文件: <?xml version="1.0" encoding="UTF-8"?> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>spring-boot</artifactId> <version>0.0.1-SNAPSHOT</version> <name>spring-boot</name> <description>Demo project for Spring Boot</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <!-- 启动web支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 添加单元测试 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- 添加处理器,spring-boot默认加载的是yml文件,这个配置就是用于引入传统的xml或properties配置 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> 报错类: 报错提示: 为什么已经引入了spring-boot-starter-test,还要让我配置呢? 报错信息位置下可以找到对应的类,只拿一个例子出来: 依赖包:

laowang554

Golang 调用 AliDNS API,得到`SignatureDoesNotMatch`错误

Golang调用 AliDNS API,得到SignatureDoesNotMatch错误,源码: func sendRequest(httpMethod string, path string, query map[string]string) error { if query == nil { query = make(map[string]string) } canonicalizedString := signRequest(httpMethod, path, query) uri := aliyunBaseUrl + path + "?" + canonicalizedString var err error targetUrl, err := url.Parse(uri) if err != nil { return err } request := &http.Request{ Method: httpMethod, ProtoMajor: 1, ProtoMinor: 1, URL: targetUrl, } httpClient := &http.Client{} response, err := httpClient.Do(request) if err != nil { return err } defer response.Body.Close() bodyBytes, _ := ioutil.ReadAll(response.Body) log.Println(string(bodyBytes)) if response.StatusCode != 200 { log.Println(response.Status) return errors.New(response.Status) } return nil } func signRequest(httpMethod string, path string, query map[string]string) string { // https://help.aliyun.com/document_detail/29745.html?spm=a2c4g.11186623.6.618.51e67ebb2zKj8K // set common parameters query["Format"] = "JSON" // 返回值的类型,支持JSON与XML。默认为XML query["Version"] = "2015-01-09" // API版本号,为日期形式:YYYY-MM-DD,本版本对应为2015-01-09 query["AccessKeyId"] = accessKeyId // 阿里云颁发给用户的访问服务所用的密钥ID query["SignatureMethod"] = "HMAC-SHA1" // 签名方式 query["Timestamp"] = time.Now().UTC().Format(time.RFC3339) // 请求的时间戳。日期格式按照ISO8601标准表示,并需要使用UTC时间。 query["SignatureVersion"] = "1.0" // 签名算法版本 query["SignatureNonce"] = generateGUID() // 唯一随机数,用于防止网络重放攻击。用户在不同请求间要使用不同的随机数值 // 1.使用请求参数构造规范化的请求字符串(Canonicalized Query String) // a) 按照参数名称的字典顺序对请求中所有的请求参数(包括文档中描述的“公共请求参数”和给定了的请求接口的自定义参数 // 但不能包括“公共请求参数”中提到Signature参数本身)进行排序。 // 注意:此排序严格大小写敏感排序。 keys := []string{} for key, _ := range query { keys = append(keys, key) } sort.Strings(keys) // b) 对每个请求参数的名称和值进行编码。名称和值要使用UTF-8字符集进行URL编码 // c) 对编码后的参数名称和值使用英文等号(=)进行连接。 // d) 再把英文等号连接得到的字符串按参数名称的字典顺序依次使用&符号连接,即得到规范化请求字符串。 var buffer bytes.Buffer for _, key := range keys { if buffer.Len() > 0 { buffer.WriteByte('&') } buffer.WriteString(percentEncode(key)) buffer.WriteByte('=') buffer.WriteString(percentEncode(query[key])) } canonicalizedString := buffer.String() // 使用上一步构造的规范化字符串按照下面的规则构造用于计算签名的字符串: // StringToSign= HTTPMethod + “&” + percentEncode(“/”) + ”&” + percentEncode(CanonicalizedQueryString) // 其中HTTPMethod是提交请求用的HTTP方法,比如GET。 buffer.Reset() buffer.WriteString(httpMethod) buffer.WriteByte('&') buffer.WriteString(percentEncode(path)) buffer.WriteByte('&') buffer.WriteString(percentEncode(canonicalizedString)) stringToSign := buffer.Bytes() log.Println("stringToSign = ", string(stringToSign)) // 按照RFC2104的定义,使用上面的用于签名的字符串计算签名HMAC值。 // 注意:计算签名时使用的Key就是用户持有的Access Key Secret并加上一个“&”字符(ASCII:38),使用的哈希算法是SHA1。 key := []byte(accessKeySecret + "&") mac := hmac.New(sha1.New, key) mac.Write(stringToSign) bytes := mac.Sum(nil) // 按照Base64编码规则把上面的HMAC值编码成字符串,即得到签名值(Signature)。 signature := base64.RawStdEncoding.EncodeToString(bytes) // 将得到的签名值作为Signature参数添加到请求参数中,即完成对请求签名的过程。 // 注意:得到的签名值在作为最后的请求参数值提交给DNS服务器的时候,要和其他参数一样,按照RFC3986的规则进行URL编码) query["Signature"] = signature return canonicalizedString + "&Signature=" + percentEncode(signature) } func generateGUID() string { b := make([]byte, 16) _, err := rand.Read(b) if err != nil { log.Fatal(err) } return fmt.Sprintf("%X-%X-%X-%X-%X", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) } // RFC3986 func percentEncode(str string) string { // URL编码的编码规则是: // i. 对于字符 A-Z、a-z、0-9以及字符“-”、“_”、“.”、“~”不编码; // ii. 对于其他字符编码成“%XY”的格式,其中XY是字符对应ASCII码的16进制表示。比如英文的双引号(”)对应的编码就是%22 // iii. 对于扩展的UTF-8字符,编码成“%XY%ZA…”的格式; // iv. 需要说明的是英文空格( )要被编码是%20,而不是加号(+)。 // 注:一般支持URL编码的库(比如Java中的java.net.URLEncoder)都是按照“application/x-www-form-urlencoded”的MIME类型的规则进行编码的。 // 实现时可以直接使用这类方式进行编码,把编码后的字符串中加号(+)替换成%20、星号(*)替换成%2A、%7E替换回波浪号(~),即可得到上述规则描述的编码字符串。 encoded := url.QueryEscape(str) encoded = strings.Replace(encoded, "+", "%20", -1) encoded = strings.Replace(encoded, "*", "%2A", -1) encoded = strings.Replace(encoded, "%7E", "~", -1) return encoded } 使用如下代码进行调用 query := make(map[string]string) query["Action"] = "DescribeDomainRecords" query["DomainName"] = "013201.cn" sendRequest("GET", "/", query) AliDNS返回400错误 { "Recommend": "https://error-center.aliyun.com/status/search?Keyword=SignatureDoesNotMatch&source=PopGw", "Message": "Specified signature is not matched with our calculation. server string to sign is:GET&%2F&AccessKeyId%3DLTAIiEdhtqF0O4Fd%26Action%3DDescribeDomainRecords%26DomainName%3D013201.cn%26Format%3DJSON%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3D0B1C5177-FA5B-46D5-BF71-CC7CC958550F%26SignatureVersion%3D1.0%26Timestamp%3D2019-03-07T03%253A24%253A47Z%26Version%3D2015-01-09", "RequestId": "E9A8E624-A702-47AA-8ABC-8CFF20B4989A", "HostId": "alidns.aliyuncs.com", "Code": "SignatureDoesNotMatch" } Golang中 log.Println("stringToSign = ", string(stringToSign)) 那行的输出为: 2019/03/07 11:24:47 main.go:204: stringToSign = GET&%2F&AccessKeyId%3DLTAIiEdhtqF0O4Fd%26Action%3DDescribeDomainRecords%26DomainName%3D013201.cn%26Format%3DJSON%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3D0B1C5177-FA5B-46D5-BF71-CC7CC958550F%26SignatureVersion%3D1.0%26Timestamp%3D2019-03-07T03%253A24%253A47Z%26Version%3D2015-01-09 程序执行中的stringToSign 和服务器返回的server string to sign 完全一样! 接下来我怀疑HMAC签名有问题,我将所有的参数都换得和文档中的一样,得到的signature与文档中的完全一样! 然后我又检查了accessKeyId和accessKeySecret, 它们和控制台中设置的 完全一样! 我甚至尝试重新建一个Access KEY, 得到的还是同样的错误。 请问各位大拿到底哪里出了问题?

一码平川MACHEL

无法创建文件notepad txt utf-8

我创建了该文件,但它仍然是ANSI而不是utf-8。 import os def create_text_file(forder_path, count): for i in range(count): name = "{}.txt".format(i + 1) text_file = os.path.join(forder_path, name) with open(text_file, "w", encoding="UTF-8") as file: pass count = int(input("n count:")) create_text_file("C:/Users/m/Desktop/n/Text1", count) 本问题及下方已被采纳的回答均来自云栖社区【Python技术进阶大群】。https://yq.aliyun.com/articles/690084 点击链接欢迎加入社区大社群。

ytb58

收到无效字节,将禁用 UTF-8 编码。请在站点管理器中强制选择 UTF-8 编码

您好,我在用FileZilla登录FTP时有以上的提示。我在站点管理器-新站点-字符集中选强制UTF-8编码,结果又出来以下提示:响应: 220-Microsoft FTP Service响应: 220 欢迎您使用万网主机,如果您FTP登陆账户验证失败,请登陆主机控制面板:cp.hichina.com进行口令重置

社区小助手

Pyspark - UnicodeEncodeError:'ascii'编解码器无法编码字符

在尝试将数据插入Oracle DB时,在运行以下程序时获得unicodeerror。 -- coding: utf-8 -- import unicodedata from pyspark.sql import SparkSessionfrom pyspark.sql import SQLContextfrom pyspark.sql.types import *from pyspark.sql.functions import udfimport sysprint(sys.getdefaultencoding()) u = 'abcdé'a = 'Austròalia'print(u)print(a) spark = SparkSession.builder.master("local") \ .appName("Unicode_Error") \ .getOrCreate() sqlContext = SQLContext(spark) l = [(340, 'India',1),(340, 'Canada',2),(341, u'abcdé',3),(340, 'Japan',4),(341, u'Austròalia',5),(341, 'China',6)]df = sqlContext.createDataFrame(l, ['CUSTOMER_ID', 'COUNTRY', 'LINENUMBER'])df.show() data_tuples = [tuple(x) for x in df.rdd.collect()] print(str(data_tuples)) print(type(data_tuples)) query = "INSERT INTO CUSTOMERS VALUES (:1, :2, :3)"cur = con.cursor()cur.prepare(query)cur.executemany(None, data_tuples)con.commit()cur.close()con.close()在设置PYTHONIOENCODING=utf8之前设置了Spark作业,解决了dataframe.show()的问题。并且还# -- coding: utf-8 --帮助解决了python打印语句。 虽然现在我甚至在数据帧正确显示数据后出现错误。将数据框转换为列表是问题倾向于发生的地方,请您指出还需要做些什么。 asciiabcdé Austròalia CUSTOMER_ID COUNTRY LINENUMBER 340 India 1 340 Canada 2 341 abcdé 3 340 Japan 4 341 Austròalia 5 341 China 6 [(340, u'India', 1), (340, u'Canada', 2), (341, u'abcdxe9', 3), (340, u'Japan', 4), (341, u'Austrxf2alia', 5), (341, u'China', 6)] Traceback (most recent call last): cur.executemany(None, data_tuples)UnicodeEncodeError: 'ascii' codec can't encode character u'xe9' inposition 4: ordinal not in range(128) 元组列表有unicode数据,并且encode不能使用unicode数据,但打印出元组列表中的每个元素给了我确切的输出,如下所示 [('340', "u'India'", '1'), ('340', "u'Canada'", '2'), ('341', "u'abcd\xe9'", '3'), ('340', "u'Japan'", '4'), ('341', "u'Austr\xf2alia'", '5'), ('341', "u'China'", '6')] India340India1340Canada2341abcdé3340Japan4341Austròalia5341China6

社区小助手

Spark无法使用JDBC think 驱动程序连接到Ignite

我正在使用Java 8,Spark 2.1.1,Ignite 2.5和BoneCP 0.8.0 Maven pom.xml看起来像这样: <?xml version="1.0" encoding="UTF-8"?> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>test</groupId> <artifactId>ignite-tester</artifactId> <version>1.0-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> <java.version>1.8</java.version> <kafka.version>0.10.1.2.6.2.0-205</kafka.version> <spark.version>2.1.1.2.6.2.0-205</spark.version> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>spark.IgniteTester</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.ignite</groupId> <artifactId>ignite-core</artifactId> <version>2.5.0</version> </dependency> <dependency> <groupId>com.jolbox</groupId> <artifactId>bonecp</artifactId> <version>0.8.0.RELEASE</version> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-sql-kafka-0-10_2.11</artifactId> <version>${spark.version}</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-sql_2.11</artifactId> <version>${spark.version}</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-streaming_2.11</artifactId> <version>${spark.version}</version> <scope>compile</scope> </dependency> </dependencies> 我的项目编译成一个'fat'jar,它包含所有依赖项,但在Spark集群上运行下一个代码时:public static void main(String[] args) { try { Class.forName("org.apache.ignite.IgniteJdbcThinDriver").newInstance(); BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl("jdbc:ignite:thin://myhost:10840;user=myusername;password=mypassword"); pool = new BoneCP(config); } catch (Exception e) { logger.error("could not load Ignite driver", e); return; } }结果以下异常: ERROR IgniteTester: could not load Ignite driverjava.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:ignite:thin://myhost:10840;user=myusername;password=mypassword, username = null. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------java.sql.SQLException: No suitable driver found for jdbc:ignite:thin://myhost:10840;user=myusername;password=mypassword at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:208) at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:361) at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416) at spark.IgniteTester.main(IgniteTester.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit $$ runMain(SparkSubmit.scala:751) at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187) at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212) at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126) at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.jolbox.bonecp.PoolUtil.generateSQLException(PoolUtil.java:192) at com.jolbox.bonecp.BoneCP.(BoneCP.java:422) at spark.IgniteTester.main(IgniteTester.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit $$ runMain(SparkSubmit.scala:751) at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187) at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212) at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126) at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala) Caused by: java.sql.SQLException: No suitable driver found for jdbc:ignite:thin://myhost:10840;user=myusername;password=mypassword at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:208) at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:361) at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416) ... 10 more 提交脚本如下所示: spark-submit \--class spark.IgniteTester \--master yarn \--deploy-mode master \--driver-memory 1g \--executor-cores 1 \--num-executors 1 \--executor-memory 1664mb \ignite-tester.jar使用“本地”Spark实例时,它使用think JDBC驱动程序连接到Ignite。

社区小助手

从csv计数Spark数据帧,返回错误的结果

我在Spark 2.2中打开了几个“csv”文件,但是当我执行“计数”时它会返回10000000条记录,而实际上它是6000000条记录,当我在python或Alteryx中使用Pandas检查它时,它会给出正确的数字。 scala> val df=spark.read.format("com.databricks.spark.csv").option("header", "true").option("inferSchema","true").option("encoding", "UTF-8").load("/detalle/*.csv") df: org.apache.spark.sql.DataFrame = [KEY: string, UNIQ: string ... 101 more fields] scala> df.count res13: Long = 10093371

社区小助手

强制maven使用本地依赖

我有一个使用spark graphX模块的Spark代码。我需要在graphX中进行更改并强制我的项目使用graphX的这个修改版本。为了做到这一点,我首先从spark源代码中取出了graphx模块并独立编译。然后我在我的应用程序pom.xml文件中指定依赖项,该文件的范围是“system”。有我的应用程序pom。 <?xml version="1.0" encoding="UTF-8"?>http://maven.apache.org/maven-v4_0_0.xsd">edu.asu.gears.examples.sparkPageRankjar"PageRank"1.04.0.0 <java.version>1.8.0</java.version> <scala.version>2.11.8</scala.version> <scala.binary.version>2.11</scala.binary.version> <scala.tools.version>2.11</scala.tools.version> <spark.version>2.3.2</spark.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <blaze.version>1.0</blaze.version> <blaze.base>/home/user/sbiookag/blaze-master</blaze.base> <pluginRepository> <id>scala-tools.org</id> <name>Scala-tools Maven2 Repository</name> <url>http://scala-tools.org/repo-releases</url> </pluginRepository> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-graphx_${scala.binary.version}</artifactId> <version>${spark.version}</version> <scope>system</scope> <systemPath>${blaze.base}/examples/pageRank/APPs/GraphXFPGAApp/graphx/target/spark-graphx_2.11-3.0.0-SNAPSHOT.jar</systemPath> </dependency> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>${scala.version}</version> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-core_${scala.binary.version}</artifactId> <version>${spark.version}</version> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-mllib_${scala.binary.version}</artifactId> <version>${spark.version}</version> </dependency> <!-- <dependency> <groupId>org.apache.spark</groupId> <artifactId>blaze_${scala.binary.version}</artifactId> <version>1.0.1</version> </dependency> --> <plugins> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <executions> <execution> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> </plugins> 当我编译我的代码时,它仍然下载graphx依赖项,似乎它在运行时也使用原始的jar文件。我真的不知道如何解决这个问题。

社区小助手

路径参考问题

ackage com.example.lambda1 import spark.Spark.get fun main(args: Array) { println("Hello, World") get( path: "/hello") { req, res -> "Hello World" } } 我正在使用IntellJ Community Edition IntelliJ IDEA 2018.3 (Community Edition)Build #IC-183.4284.148, built on November 20, 2018JRE: 1.8.0_152-release-1343-b15 amd64JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.oWindows 10 10.0在创建新项目时,我从“IJ”中选择“Maven”,然后单击“从archtype创建”并选择“org.jetbrains.kotlin-archetype-jvm”。 POM文件已更新为。。。 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <kotlin.version>1.3.10</kotlin.version> <kotlin.code.style>official</kotlin.code.style> <junit.version>4.12</junit.version> <spark.version>2.6.0</spark.version> 我在这里添加了“spark.version”。不确定版本是否考虑录制视频创建日期。 我添加了以下内容 <dependency> <groupId>com.sparkjava</groupId> <artifactId>spark-core</artifactId> <version>${spark.version}</version> </dependency> 这似乎是一个“maven / spark”问题,因为我运行一个kotlin hello world app就好了。

potatomato

HSF+spring+maven 总是报ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

昨天还能启动,今天就报错了,找不到spring加载配置文件的监听器。报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener Pandora正常启动 web.xml配置 br> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <display-name>model</display-name> <!-- Spring的配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> <!-- 防止Spring内存溢出监听器 --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!-- 编码过滤器 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> maven确认已经加入了 目录 用普通的tomcat能正常启动,用alitomcat就找不到监听器,spring无法启动。。。用官网的hsf示例启动也是报同样的错,昨天我还能启动呢,今天就启动不了了,搞了一天了,有人遇到过这样的情况吗

易士联

python3安装sdk成功,但是仍然显示 ImportError: No module named 'aliyunsdkcore'

d:\python\aliyun>python --version Python 3.5.4 d:\python\aliyun>pip install aliyun-python-sdk-core-v3 Collecting aliyun-python-sdk-core-v3 Installing collected packages: aliyun-python-sdk-core-v3 Successfully installed aliyun-python-sdk-core-v3-2.11.0 You are using pip version 18.0, however version 18.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. d:\python\aliyun>python ossSTS客户端.py Traceback (most recent call last): File "ossSTS客户端.py", line 8, in <module> from aliyunsdkcore import client ImportError: No module named 'aliyunsdkcore' python代码 # -*- coding: utf-8 -*- from aliyunsdkcore import client from aliyunsdksts.request.v20150401 import AssumeRoleRequest import json import oss2

似水的流年

程序员永远无法避免的话题---乱码的处理!

为什么说乱码是中国程序员无法避免的话题呢?这个首先要从编码机制上说起,大家都是中文和英文的编码格式不是一样,解码也是不一样的!如果中国的程序员不会遇到乱码,那么只有使用汉语编程。 比如java的乱码有很多种情况: 1、关于配置Tomcat的URIEncoding 问题:程序需要发送http GET请求到服务器,请求的参数中包含了中文字符。程序中参数为UTF-8格式,且经过了UTF-8 URL编码再发送。使用的tomcat服务器,但服务器端后台程序中取到的参数的中文是乱码。 解决方法:修改Tomcat的Server.xml,在Connector标签中加上URLEncoding参数。 maxSpareThreads="75" enableLookups="false" redirectPort="8443"acceptCount="100" debug="99" connectionTimeout="20000"disableUploadTimeout="true" URIEncoding="UTF-8"/> 2、http请求乱码问题 post请求出现乱码: 解决方法:在servlet页面添加response.setCharcacterEncoding("utf-8") get请求出现乱码: 解决方法:在后台获取字符串后对编码进行转化,如常见的编码ISO-8859-1,代码如下 String name = request.getParameter("name");name=new String(name.getBytes("ISO-8859-1","utf-8"))           3、Html中文乱码 问题:htmll出现乱码的主要原因是html源代码内中文字内容与html编码不同造成。网页的编码是gbk,而中文的是utf-8; 解决方法:在页面顶部......中加上以下代码 4、jsp页面出现乱码 问题:开发人员开发jsp应该拥有良好的编码意识,jsp顶部应该首先明确编码是什么? 解决方法:在页面顶部加上以下语句 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 大家来说说:你在编程时候遇到过乱码吗?遇到乱码你是如何解决问题的?快分享一下您的宝贵经验!

pckkk

web.xml添加过滤器,打war包发布没有效果

java web项目,在web.xml里添加了编码过滤器,用idea直接启动有效果没有中文乱码,打成war包放在tomcat下启动,访问项目就会出问题 <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

求再来一发

接口从钉钉取数据 不合法的UserID列表长度

不合法的UserID列表长度 不知道怎么解决public static JSONArray getCardList(String accessToken, String workDateFrom, String workDateTo, String offset, String limit){ String recordUrl = "https://oapi.dingtalk.com/attendance/listRecord?access_token="+accessToken; JSONObject jsonObject = new JSONObject(); // jsonObject.put("userIds", userIds); jsonObject.put("workDateFrom",workDateFrom); jsonObject.put("workDateTo",workDateTo); jsonObject.put("offset",offset); jsonObject.put("limit",limit); String result = test.doPost(recordUrl,jsonObject,"utf-8"); JSONObject resutJSON = jsonObject.parseObject(result); String msg = (String)resutJSON.get("errmsg"); JSONArray jsonArray = null; if("ok".equals(msg)){ jsonArray = (JSONArray) resutJSON.get("recordresult"); } return jsonArray; } 请问大神们,能帮帮么

giant_lizard

vsftp, Java代码登录能成功,上传下载文件超时

CentOS 7.2 64建立的vsftp, Java代码登录能成功,上传下载文件超时 ,工具操作没有任何问题,求大佬解决! /** * 向FTP服务器上传文件 * * @param host FTP服务器hostname * @param port FTP服务器端口 * @param username FTP登录账号 * @param password FTP登录密码 * @param basePath FTP服务器基础目录 * @param filePath FTP服务器文件存放路径。例如分日期存放:/2015/01/01。文件的路径为basePath+filePath * @param fileName 上传到FTP服务器上的文件名 * @param input 输入流 * @return 成功返回true,否则返回false */ public static boolean uploadFile(String host, int port, String username, String password, String basePath, String filePath, String fileName, InputStream input) { Boolean result = false; FTPClient ftp = new FTPClient(); ftp.setControlEncoding("UTF-8"); try { int replyCode; ftp.connect(host, port);// 连接FTP服务器 // 如果采用默认端口,可以使用ftp.connect(host)的方式直接连接FTP服务器 ftp.login(username, password);// 登录 replyCode = ftp.getReplyCode(); //是否成功登陆ftp if (!FTPReply.isPositiveCompletion(replyCode)) { ftp.disconnect(); return result; } //切换到上传目录 if (!ftp.changeWorkingDirectory(basePath + filePath)) { //如果目录不存在创建目录 String[] dirs = filePath.split("/"); String tempPath = basePath; for (String dir : dirs) { if (null == dir || "".equals(dir)) continue; tempPath += "/" + dir; if (!ftp.changeWorkingDirectory(tempPath)) { if (!ftp.makeDirectory(tempPath)) { return result; } else { ftp.changeWorkingDirectory(tempPath); } } } } //设置上传文件的类型为二进制类型 ftp.setFileType(FTP.BINARY_FILE_TYPE); ftp.setControlEncoding("UTF-8"); ftp.enterLocalPassiveMode(); ftp.setFileTransferMode(FTP.STREAM_TRANSFER_MODE); //上传文件 if (!ftp.storeFile(fileName, input)) { return result; } input.close(); ftp.logout(); result = true; } catch (IOException e) { e.printStackTrace(); } finally { if (ftp.isConnected()) { try { ftp.disconnect(); } catch (IOException ioe) { } } } return result; }

童趣网络

OSS下载链接用360浏览器出现The characters encoding must be utf-8报错信息

InvalidArgumentThe characters encoding must be utf-8.5AD6A10A6206B0E046E11767tq.oss-cn-huhehaote.aliyuncs.comobject11/ ƴ u 07_ .mp4