1.IIS部署
ISS部署网站--HTTP 错误 404.17 - Not Found 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理。 - 姜小珂 - 博客园
2.复杂JPA更新
/**
*复杂JPA操作 使用@Query()自定义sql语句 根据业务id UId去更新整个实体
* 删除和更新操作,需要@Modifying和@Transactional注解的支持
*
* 更新操作中 如果某个字段为null则不插入,否则插入【注意符号和空格位置】
*/
@Transactional
@Modifying
@Query(value = "insert into bi_user (user_code,user_type,username,realname,password,avatar,birthday," +
"sex,email,phone,third_id,third_type,create_by,update_by,age,parents_name,school,campus," +
"grade,the_class,integral) values (" +
"CASE WHEN :#{#users.userCode} IS NULL THEN user_code ELSE :#{#users.userCode} END ," +
"CASE WHEN :#{#users.userType} IS NULL THEN user_type ELSE :#{#users.userType} END ," +
"CASE WHEN :#{#users.username} IS NULL THEN username ELSE :#{#users.username} END ," +
"CASE WHEN :#{#users.realname} IS NULL THEN realname ELSE :#{#users.realname} END ," +
"CASE WHEN :#{#users.password} IS NULL THEN password ELSE :#{#users.password} END ," +
"CASE WHEN :#{#users.avatar} IS NULL THEN avatar ELSE :#{#users.avatar} END ," +
"CASE WHEN :#{#users.birthday} IS NULL THEN birthday ELSE :#{#users.birthday} END ," +
"CASE WHEN :#{#users.sex} IS NULL THEN sex ELSE :#{#users.sex} END ," +
"CASE WHEN :#{#users.email} IS NULL THEN email ELSE :#{#users.email} END ," +
"CASE WHEN :#{#users.phone} IS NULL THEN phone ELSE :#{#users.phone} END ," +
"CASE WHEN :#{#users.thirdId} IS NULL THEN third_id ELSE :#{#users.thirdId} END ," +
"CASE WHEN :#{#users.thirdType} IS NULL THEN third_type ELSE :#{#users.thirdType} END ," +
"CASE WHEN :#{#users.createBy} IS NULL THEN create_by ELSE :#{#users.createBy} END ," +
"CASE WHEN :#{#users.updateBy} IS NULL THEN update_by ELSE :#{#users.updateBy} END ," +
"CASE WHEN :#{#users.age} IS NULL THEN age ELSE :#{#users.age} END ," +
"CASE WHEN :#{#users.parentsName} IS NULL THEN parents_name ELSE :#{#users.parentsName} END ," +
"CASE WHEN :#{#users.school} IS NULL THEN school ELSE :#{#users.school} END ," +
"CASE WHEN :#{#users.campus} IS NULL THEN campus ELSE :#{#users.campus} END ," +
"CASE WHEN :#{#users.grade} IS NULL THEN grade ELSE :#{#users.grade} END ," +
"CASE WHEN :#{#users.theClass} IS NULL THEN the_class ELSE :#{#users.theClass} END ," +
"CASE WHEN :#{#users.integral} IS NULL THEN integral ELSE :#{#users.integral} END " +
")", nativeQuery = true)
int insertAndFlush(@Param("users") Users users);
3.
4.leetcodeLoading...
参考答案
class Solution {
public int maxTaskAssign(int[] tasks, int[] workers, int pills, int strength) {
Arrays.sort(tasks);
Arrays.sort(workers);
boolean[]usedWorkerInFirstRound=new boolean[workers.length];
int maxPossibleUsedTaskLen=Math.min(tasks.length,workers.length);
int curToJudgeWorkIndex=0;
for(int i=0;i<maxPossibleUsedTaskLen;i++){
while (curToJudgeWorkIndex<workers.length&&workers[curToJudgeWorkIndex]<tasks[i]){
curToJudgeWorkIndex++;
}
if(curToJudgeWorkIndex==workers.length){
break;
}
usedWorkerInFirstRound[curToJudgeWorkIndex]=true;
curToJudgeWorkIndex++;
}
for (int i=workers.length-1;i>=0;i--){
if(pills==0){
break;
}
if(!usedWorkerInFirstRound[i]){
workers[i]+=strength;
pills--;
}
}
for (int i=workers.length-1;i>=0;i--){
if(pills==0){
break;
}
if(usedWorkerInFirstRound[i]){
workers[i]+=strength;
pills--;
}
}
Arrays.sort(workers);
int res=0;
curToJudgeWorkIndex=0;
for(int i=0;i<maxPossibleUsedTaskLen;i++){
while (curToJudgeWorkIndex<workers.length&&workers[curToJudgeWorkIndex]<tasks[i]){
curToJudgeWorkIndex++;
}
if(curToJudgeWorkIndex==workers.length){
break;
}
res++;
curToJudgeWorkIndex++;
}
return res;
}
}
5.浏览器模拟跨域
var token= "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGgiOiJBY2NvdW50RGVsZXRlLEFjY291bnRJbnNlcnQsQWNjb3VudE1vZGlmeSxBY2NvdW50UXVlcnksRGF0YVNvdXJjZURlbGV0ZSxEYXRhU291cmNlTW9kaWZ5LERhdGFTb3VyY2VRdWVyeSxEYXRhU291cmNlVXBsb2FkLFNjcmVlbkRhdGFEZWxldGUsU2NyZWVuRGF0YUluc2VydCxTY3JlZW5EYXRhTGlzdCxTY3JlZW5EYXRhTW9kaWZ5LFNjcmVlbkRlbGV0ZSxTY3JlZW5JbnNlcnQsU2NyZWVuTGlzdCxTY3JlZW5Nb2RpZnksVXNlckdyb3VwRGVsZXRlLFVzZXJHcm91cEluc2VydCxVc2VyR3JvdXBNb2RpZnksVXNlckdyb3VwUXVlcnkiLCJleHAiOjE2MTczNDU4Mzh9.-RMmD554l5uaoT5cTu_tywonRYZ1TW0fBzXEqWxX8zJQmi2X7OPqDnnBXbiF6z3tGnmHqlAqkklakdUkM8V_nA";
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://localhost:8292/v2a/back/emergency/emergencyDuty');
xhr.setRequestHeader("Authorization",token);
xhr.send(null);
xhr.onload = function(e) {
var xhr = e.target;
console.log(xhr.responseText);
}
6.跨域调用不能调用response.reset()
7.PostgreSQL pg_dump&psql 数据的备份与恢复
PostgreSQL pg_dump&psql 数据的备份与恢复
Usage:
pg_dump [OPTION]... [DBNAME] 数据库名放最后,不指定默认是系统变量PGDATABASE指定的数据库。
General options:(一般选项)
-f, --file=FILENAME output file or directory name导出后保存的文件名
-F, --format=c|d|t|p output file format (custom, directory, tar,导出文件的格式
plain text (default))
-j, --jobs=NUM use this many parallel jobs to dump并行数
-v, --verbose verbose mode 详细模式
-V, --version output version information, then exit输出版本信息, 然后退出
-Z, --compress=0-9 compression level for compressed formats被压缩格式的压缩级别
--lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock在等待表锁超时后操作失败
-?, --help show this help, then exit显示此帮助信息, 然后退出
Options controlling the output content:(控制输出的选项)
-a, --data-only dump only the data, not the schema只导出数据,不包括模式
-b, --blobs include large objects in dump在转储中包括大对象
-c, --clean clean (drop) database objects before recreating在重新创建之前,先清除(删除)数据库对象
-C, --create include commands to create database in dump在转储中包括命令,以便创建数据库(包括建库语句,无需在导入之前先建数据库)
-E, --encoding=ENCODING dump the data in encoding ENCODING转储以ENCODING形式编码的数据
-n, --schema=SCHEMA dump the named schema(s) only只转储指定名称的模式
-N, --exclude-schema=SCHEMA do NOT dump the named schema(s)不转储已命名的模式
-o, --oids include OIDs in dump在转储中包括 OID
-O, --no-owner skip restoration of object ownership in在明文格式中, 忽略恢复对象所属者
plain-text format
-s, --schema-only dump only the schema, no data只转储模式, 不包括数据(不导出数据)
-S, --superuser=NAME superuser user name to use in plain-text format在转储中, 指定的超级用户名
-t, --table=TABLE dump the named table(s) only只转储指定名称的表
-T, --exclude-table=TABLE do NOT dump the named table(s)只转储指定名称的表
-x, --no-privileges do not dump privileges (grant/revoke)不要转储权限 (grant/revoke)
--binary-upgrade for use by upgrade utilities only只能由升级工具使用
--column-inserts dump data as INSERT commands with column names以带有列名的INSERT命令形式转储数据
--disable-dollar-quoting disable dollar quoting, use SQL standard quoting取消美元 (符号) 引号, 使用 SQL 标准引号
--disable-triggers disable triggers during data-only restore在只恢复数据的过程中禁用触发器
--exclude-table-data=TABLE do NOT dump data for the named table(s)以INSERT命令,而不是COPY命令的形式转储数据
--inserts dump data as INSERT commands, rather than COPY
--no-security-labels do not dump security label assignments
--no-synchronized-snapshots do not use synchronized snapshots in parallel jobs
--no-tablespaces do not dump tablespace assignments不转储表空间分配信息
--no-unlogged-table-data do not dump unlogged table data
--quote-all-identifiers quote all identifiers, even if not key words
--section=SECTION dump named section (pre-data, data, or post-data)
--serializable-deferrable wait until the dump can run without anomalies
--use-set-session-authorization
use SET SESSION AUTHORIZATION commands instead of
ALTER OWNER commands to set ownership
Connection options:(控制连接的选项)
-d, --dbname=DBNAME database to dump 数据库名
-h, --host=HOSTNAME database server host or socket directory数据库服务器的主机名或套接字目录
-p, --port=PORT database server port number数据库服务器的端口号
-U, --username=NAME connect as specified database user以指定的数据库用户联接
-w, --no-password never prompt for password永远不提示输入口令
-W, --password force password prompt (should happen automatically)强制口令提示 (自动)
--role=ROLENAME do SET ROLE before dump
If no database name is supplied, then the PGDATABASE environment如果没有提供数据库名字, 那么使用 PGDATABASE 环境变量的数值.
variable value is used.
Report bugs to <pgsql-bugs@postgresql.org>.
一: 纯文件格式的脚本:
示例:
1. 只导出postgres数据库的数据,不包括模式 -s
pg_dump -U postgres -f /postgres.sql -s postgres(数据库名)
2. 导出postgres数据库(包括数据)
pg_dump -U postgres -f /postgres.sql postgres(数据库名)
3. 导出postgres数据库中表test01的数据
create database "test01" with owner="postgres" encoding='utf-8';(单引号,双引号不能错)
pg_dump -U postgres -f /postgres.sql -t test01 postgres(数据库名)
4. 导出postgres数据库中表test01的数据,以insert语句的形式
pg_dump -U postgres -f /postgres.sql -t test01 --column-inserts postgres(数据库名)
5. 恢复数据到bk01数据库
psql -U postgres -f /postgres.sql bk01
二、 使用归档文件格式:SQL转储
pg_dump --help 查看详细参数及作用
整库操作
pg_dump -C -U postgres enterprise_service_management_db > ./enterprise_service_management_db_data_with_create.bak.sql
pg_dump -C -U postgres enterprise_service_management_db > ./enterprise_service_management_db_data_withAllRoleAndPermission_with_create.bak.sql
pg_dump -C -s -U postgres enterprise_service_management_db > ./enterprise_service_management_db_structure_only_with_create.bak.sql
单表操作
pg_dump -U postgres -t user_info enterprise_service_management_db > ./user_info.bak.sql (----未测试)
pg_dump -c -U postgres -p 5435 -t action municipal_dev > c:\Users\Administrator\Desktop\municipal\database_dump\2020-04-01\action_dev_with_update.bak.sql(推荐使用)
pg_dump -c --column-inserts -U postgres -p 5435 -t inspection_report municipal_dev > c:\Users\Administrator\Desktop\municipal\database_dump\2020-04-03\inspection_report.bak.sql
pg_dump -C -U postgres -p 5435 municipal_v2.0_dev > C:\Users\Administrator\Desktop\municipal\database_dump\2020-6-19\municipal_v 2.0_dev.bak
注:如果提示命令行参数过多,那么大概率是路径占用空间太多,这个时候如下处理,使用双引号 -->""<-- 将路径包裹
pg_dump -C -U postgres -p 5435 municipal_v2.0_dev > "C:\Users\Administrator\Desktop\municipal\database_dump\2020-8-19\municipal_v 2.0_dev.bak.sql"
解释
-C: --create 在转储中包含创建Database的命令,以便于创建数据库,适用于数据库转移
-s: --schema-only 只转储模式,不包含数据
-c: --clean 在重新创建之前,先清除(删除)数据库对象
SQL转储恢复
当转储的格式为纯文本形式:(不论转储文件是整库还是库中的单表,都适用 ----未测试)
整库
psql -U postgres -p 5432 < .\enterprise_service_management_db_structure_only.bak.sql
单表
psql -U postgres(用户名) -p 5432 -d 数据库名(缺省时同用户名) < C:\fulldb.sql
psql -U postgres -p 5435 -d municipal_v2.0_dev < C:\Users\12863\Desktop\pumping\
命令行连接使用数据库
\connect enterprise_service_management_db
municipal_v2.0_dev数据库名和sql里面的文件名一样!!!!
psql -U postgres -p 5432 -d municipal_v2.0_dev < C:\Users\12863\Desktop\外协发过来的泵站系统资料\外协 提交的最新的数据库\t_pumping_station_data(1)(1).sql
8.gradle compile和implement的区别
安卓中compile和implement的区别_FGY_u的博客-CSDN博客_android compile
compile对其被依赖的工程开发,implement在改工程引用
9.jvm自带工具看内存快照
jvm 内存堆hprof分析_huang552-CSDN博客
java -Xms10240m -Xmx10240m -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=headp_dump.log -Xloggc:gc.log -XX:+PrintGCDateStamps -jar com.municipal.promotion-client-1.0.0-SNAPSHOT.jar
JVM参数-XX:+HeapDumpOnOutOfMemoryError使用方法_lusa1314的博客-CSDN博客_heapdumponoutofmemoryerror
JVisualVM工具的使用 - EXTRA· - 博客园
10.maven导源码错误
Cannot connect to the Maven process. Try again later. If the problem persists, check the Maven Importing JDK settings and restart IntelliJ IDEA
download sources报错:Cannot connect to the Maven process._自己人的博客-CSDN博客
可能的原因:项目的jdk和jdk for importer版本不一致
11 MySQL 编码utf8 与 utf8mb4 utf8mb4_unicode_ci 与 utf8mb4_general_ci
https://www.jb51.net/article/186609.htm
这篇文章主要介绍了MySQL 编码utf8 与 utf8mb4 utf8mb4_unicode_ci 与 utf8mb4_general_ci的相关知识,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
参考:mysql字符集小结
utf8mb4 已成为 MySQL 8.0 的默认字符集,在MySQL 8.0.1及更高版本中将 utf8mb4_0900_ai_ci 作为默认排序规则。
新项目只考虑 utf8mb4
UTF-8 编码是一种变长的编码机制,可以用1~4个字节存储字符。
因为历史遗留问题,MySQL 中的 utf8 编码并不是真正的 UTF-8,而是阉割版的,最长只有3个字节。当遇到占4个字节的 UTF-8 编码,例如 emoji 字符或者复杂的汉字,会导致存储异常。
从 5.5.3 开始,MySQL 开始用 utf8mb4 编码来实现完整的 UTF-8,其中 mb4 表示 most bytes 4,最多占用4个字节。从 8.0 之后,将会在某个版本开始用 utf8mb4 作为默认字符编码。
设置服务器默认字符集为 utf8mb4
创建数据库时,如果没有指定字符集,会采用服务器的默认字符集。设置服务器默认字符集为 utf8mb4 可以提高便利性。
编辑 MySQL 的配置文件
只需要关心5个系统变量,这5个都改为 utf8mb4 则修改成功:
character_set_client
character_set_connection
character_set_results
character_set_server
character_set_database
my.cnf
是MySQL 的配置文件,修改之前记得先备份:
vi /etc/my.cnf
在[mysqld]下面加上default-character-set=utf8后服务器启动不了,莫名其妙。后来这么改就好了(MySQL5.7):
1 2 3 4 5 6 7 8 9 |
|
MySQL8.0 默认已经是 utf8mb4,不用改懂。如果你要改的话,配置文件如下:
1 2 3 4 5 6 7 8 |
|
重启并确认
可以看到,系统编码、连接编码、服务器和客户端编码都设置为 UTF-8了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
MySQL 中字符集相关变量
character_set_client:客户端请求数据的字符集
character_set_connection:从客户端接收到数据,然后传输的字符集
character_set_database:默认数据库的字符集,无论默认数据库如何改变,都是这个字符集;如果没有默认数据库,那就使用 character_set_server指定的字符集,这个变量建议由系统自己管理,不要人为定义。
character_set_filesystem:把操作系统上的文件名转化成此字符集,即把 character_set_client转换character_set_filesystem, 默认binary是不做任何转换的
character_set_results:结果集的字符集
character_set_server:数据库服务器的默认字符集
character_set_system:存储系统元数据的字符集,总是 utf8,不需要设置
创建数据库时指定字符集为 utf8mb4
如果数据库默认字符集不是 utf8mb4,那么可以在创建数据库时指定字符集:
1 |
|
排序字符集 collation
字符除了需要存储,还需要排序或比较大小。推荐用 utf8mb4_unicode_ci,但是用 utf8mb4_general_ci 也没啥问题。
MySQL 8.0 默认的是 utf8mb4_0900_ai_ci,属于 utf8mb4_unicode_ci 中的一种,具体含义如下:
- uft8mb4 表示用 UTF-8 编码方案,每个字符最多占4个字节。
- 0900 指的是 Unicode 校对算法版本。(Unicode归类算法是用于比较符合Unicode标准要求的两个Unicode字符串的方法)。
- ai指的是口音不敏感。也就是说,排序时e,è,é,ê和ë之间没有区别。
- ci表示不区分大小写。也就是说,排序时p和P之间没有区别。
utf8mb4 已成为默认字符集,在MySQL 8.0.1及更高版本中将utf8mb4_0900_ai_ci作为默认排序规则。以前,utf8mb4_general_ci是默认排序规则。由于utf8mb4_0900_ai_ci排序规则现在是默认排序规则,因此默认情况下新表格可以存储基本多语言平面之外的字符。现在可以默认存储表情符号。如果需要重音灵敏度和区分大小写,则可以使用utf8mb4_0900_as_cs代替