-
FFmpeg命令
##MKV转MP4```#很慢/usr/local/ffmpeg/bin/ffmpeg-isource.mkv-vcodech264target.mp4/usr/local/ffmpeg/bin/ffmpeg-isource.mkv-ccopytarget.mp4#音频/usr/local/ffmpeg/bin/ffmpeg-isource.mkv-vcodeccopy-acodecaactarget.mp4```>-y默认覆盖由于录制媒体流时直接使用`-ccopy`所以导致数据之中很多的重传的错包,所以需要有些特殊处理。```Toomanypacketsbufferedforoutputstream0:1.[aac@0x24a2100]Qavg:61578.551[aac@0x24a2100]2framesleftinthequeueonclosingConversionfailed!```添加参数`-threads2`和`max_muxing_queue_size1024````ffmpeg-threads2-i000000.ts-max_muxing_queue_size1024-c:aaac-c...
FFmpeg -
ITextPdf
##Maven```com.itextpdfitextpdf${itextpdf.version}com.itextpdfitext-pdfa${itextpdf.version}com.itextpdfitext-xtra${itextpdf.version}org.apache.commonscommons-imaging1.0-alpha3```##添加附件```finalPdfFileSpecificationpdfFileSpecification=PdfFileSpecification.fileEmbedded(pdfWriter,filePath.toFile().getAbsolutePath(),title,null);//中文乱码pdfFileSpecification.setUnicodeFileName(title,true);pdfWriter.addFileAttachment(pdfFileSpecification);```##添加视频```finalPdfFileSpecificationpdfFileSpecification=PdfFileSpecification.f...
ITextPdf -
使用commons-net中的FTPClient总结
以前没有仔细研究还有测试,最近偶然升级了`commons-net`包后发现居然不能连接不上FTP,然后经过多方测试发现几个问题。##命令分隔`2.2`命令换行用的是`\n`,之后`3.0`改用了`CRLFLineReader`,使用的是`\r\n`,所有部分FTPServer会出现登陆不上问题。##超时问题```ftp.setDataTimeout(5000);ftp.setDefaultTimeout(5000);ftp.setConnectTimeout(5000);```超时时间必须设置,否者将会永久阻塞。
commons-net FTPClient -
keytool命令
##相关命令```#生成CA根证书jkskeytool-genkeypair-keyalgRSA-dname"CN=ca.acgist.com,OU=acgist,O=acgist,L=GZ,ST=GD,C=CN"-aliasca-validity3650-extbc:c-keystoreca.jks-keypass123456-storepass123456#导出ca证书keytool-exportcert-keystoreca.jks-storepass123456-aliasca-rfc-fileca.cer#生成server证书keytool-genkeypair-keyalgRSA-dname"CN=www.acgist.com,OU=acgist,O=acgist,L=GZ,ST=GD,C=CN"-aliasserver-validity3650-extku:c=dig,keyE-exteku=serverAuth-extSAN=dns:www.acgist.com,ip:127.0.0.1-keystoreserver.jks-keypass123456-storepass123456#生成se...
keytool 证书 -
Neo4j插入内存溢出
默认使用如下查询:```PortNodefindByPortId(LongportId);```但是录入一定数量就开始内存溢出了,开始找了很久没有找到原因。后来看了`debug`日志才发现,原来这个查询会级联查询所有关系,成环的关系就会导致内存溢出。旧版的`API`存在`@Depth`注解可以指定查询的深度,但是新版的没有这个注解了,所以只能改成下面这样:```@Query("MATCH(a:PortNode{portId:$portId})-[r:PortRelationship]-(z:PortNode)RETURNa,COLLECT(r),COLLECT(z)")PortNodefindByPortId(LongportId);```然后这里还有一个问题,就是`save`的时候,后面的节点关系会丢失,所以最后我改成了使用语句插入关系:```@Query("MATCH(a:PortNode{portId:$aPortId})WITHa"+"MATCH(z:PortNode{portId:$zPortId})"+"CREATE(a)-[r:PortRelationship]->(z)")```如果不要...
Neo4j java.lang.OutOfMemoryError -
记录一次SpringMVC请求一次返回两次数据错误
昨天改了很多代码,最后发现发送一次请求,返回数据的时候居然返回了两份。最后DEBUG看了下堆栈信息发现,原来是过滤器执行了两次`doFilter`:```if(LOGIN_MATCHER.matches(request)){filterChain.doFilter(request,response);}elseif(MATCHER.matches(request)){}filterChain.doFilter(request,response);```改为下面这样就没问题了:```if(LOGIN_MATCHER.matches(request)){filterChain.doFilter(request,response);}elseif(MATCHER.matches(request)){}else{filterChain.doFilter(request,response);}```这个问题真的粗心,而且很难发现问题。
SpringMVC -
SpringBoot多数据库事务管理
如果SpringBoot同时加入多个数据源,不能正确获取事务管理器,可以使用下面方法处理:```/***配置事务**配置JDBC事务事务为默认的事务,Neo4j事务需要手动指定`@Transactional(transactionManager="neo4jTransactionManager")`。**@authoracgist*/@Configuration(proxyBeanMethods=false)@Import({DataSourceAutoConfiguration.class,MybatisPlusAutoConfiguration.class})//@Import({DataSourceAutoConfiguration.class,DataSourceTransactionManagerAutoConfiguration.class,MybatisPlusAutoConfiguration.class})publicclassTransactionConfiguration{@Bean("transactionManager")@PrimarypublicDataSourceTransac...
SpringBoot TransactionManager -
SpringBoot配置转义
SpringBoot配置冒号等等转义:```acgist:cache:"[password::fail]":1```还有一个问题就是值里面如果出现`${value:default}`这种字符串,默认会被当成表达式处理掉,如果没有定义`value`配置,就会变成默认值`default`,这个时候我们就需要这样配置:```value:${$:$}{value:default}```
SpringBoot -
使用Canal + Kafka + ElasticSearch记录数据库修改历史
最近有个需求需要记录某些数据库表里面的新增修改和删除日志。开始本来想直接通过注解方式实现,但是后来看了看,实现起来比较麻烦。主要是批量修改的时候很难记录日志。所以想到使用`Canal`来监听MySQL的`binlog`,然后发送修改到Kafka,然后入库到ElasticSearch。DEMO地址:[https://gitee.com/acgist/muses/tree/master/service-parent/service-log-parent](https://gitee.com/acgist/muses/tree/master/service-parent/service-log-parent)##异常```2022-10-2716:08:58.068[destination=acgist,address=/192.168.8.187:3306,EventParser]ERRORc.a.o.canal.parse.inbound.mysql.dbsync.DirectLogFetcher-I/Oerrorwhilereadingfromclientsocketjava.io.IOException:R...
canal kafka ElasticSearch -
SpringBoot OAuth2出现401问题
最近公司要求配置一个超级管理员,不需要配置角色和权限,天然拥有所有权限。所有代码改完,返现系统认证的时候老返回`401`,后来发现原来`UserDetailsService`返回的用户信息如果没有角色,那么默认就会返回`401`了,所以给他加个角色就可以了。
SpringBoot OAuth2 401 -
Neo4j常用查询语句整理
```//忽略属性@Query("MATCHp=(a:RoomNode{roomId:$roomIdA})-[*..16]-(z:RoomNode{roomId:$roomIdZ})RETURNp,LENGTH(p)")//指定属性@Query("MATCHp=(a:RoomNode{roomId:$roomIdA})-[r:RoomRelationship*..16]-(z:RoomNode{roomId:$roomIdZ})RETURNp,LENGTH(p)")//最短路径@Query("MATCH(a:RoomNode{roomId:$roomIdA}),(z:RoomNode{roomId:$roomIdZ}),p=SHORTESTPATH((a)-[*..16]-(z))RETURNp,LENGTH(p)")//多条最短路径@Query("MATCH(a:RoomNode{roomId:$roomIdA}),(z:RoomNode{roomId:$roomIdZ}),p=ALLSHORTESTPATHS((a)-[*..16]-(z))RETURNp,LENGTH(p)")//必经避让@Query(...
Neo4j Cypher -
SpringCloud配置OAuth2权限
配置SpringCloud环境OAuth2权限问题:*配置Feign调用Token*配置内网IP允许直接访问```importjava.io.IOException;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.commons.lang3.ArrayUtils;importorg.springframework.beans.factory.annotation.Value;importorg.springframework.boot.autoconfigure.condition.ConditionalOnClass;importorg.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;importorg.springframework.context.annotation.Bean;...
SpringCloud -
Linux字体安装
最近升级了阿里云的CentOS版本,旧的字体全部没了,这里记录一下安装命令:```#查询中文字体fc-list:lang=zh#创建目录:simheimkdir-p/usr/share/fonts/simhei#拷贝字体文件:字体文件可以去到`C:\Windows\Fonts`目录下面查找yuminstallmkfontscalecd/usr/share/fonts/simheimkfontscalemdfontdir#查看结果fc-list```>如果没有安装`fc-list`执行`yuminstallfontconfig`字体安装完成应用需要重启一下才有效果
Linux ttf -
FreeMarker使用Java新版日期API
`FreeMarker`使用新版Java的事件API不能正确的格式化输出,需要添加下面配置才可以。```this.configuration.setObjectWrapper(newDefaultObjectWrapper(freemarker.template.Configuration.VERSION_2_3_31){@OverridepublicTemplateModelwrap(Objectobject)throwsTemplateModelException{if(objectinstanceofLocalDateTimelocalDateTime){returnnewSimpleDate(Timestamp.valueOf(localDateTime));}elseif(objectinstanceofLocalDatelocalDate){returnnewSimpleDate(Date.valueOf(localDate));}elseif(objectinstanceofLocalTimelocalTime){returnnewSimpleDate(Time.valueOf(localTim...
FreeMarker LocalDateTime -
OpenJDK17一些JVM参数变化
由于租用的服务器内存比较小,所以配置了一下网站的JVM参数看下有没有什么优化空间。但是配置后发现启动不了,首先提示下面错误:```UnrecognizedVMoption'PrintGCDateStamps'Error:CouldnotcreatetheJavaVirtualMachine.Error:Afatalexceptionhasoccurred.Programwillexit.```这个是由于`PrintGCDateStamps`配置已经废弃了,所以改为`-Xlog:gc::utctime`。然后还有配置日志的参数也改了:```-Xloggcisdeprecated.Willuse-Xlog:gc:./logs/gc.loginstead.Unrecognizedoption:-JARError:CouldnotcreatetheJavaVirtualMachine.Error:Afatalexceptionhasoccurred.Programwillexit.```这个就比较人性化了,直接提示该使用那个参数替换。还有很多参数都被废弃了:```[0.002s][warning][gc]-XX:+P...
OpenJDK Java JVM -
MyBatisPlus连表使用Wrapper
```SELECTa.*,b.*FROMaLEFTJOINbONa.id=b.id${ew.customSqlSegment}page(Pagepage,Wrapperew)```**注意:条件名称必须`ew`**
MyBatisPlus Wrapper 连表 -
web.xml常用配置
```www.acgist.comindex.jspindex.htmlencodingFilterorg.springframework.web.filter.CharacterEncodingFilterencodingUTF-8encodingFilter/*adminFiltercom.acgist.web.filter.AdminFilteradminFilter/admin/*pageCachingFilternet.sf.ehcache.constructs.web.filter.SimplePageCachingFiltersuppressStackTracesfalsecacheNamepageCachepageCachingFilter/imagepageCachingFilter/articlepageCachingFilter/common/*pageCachingFilter/index.jspcontextConfigLocationclasspath*:/applicationContext.xmlmvcorg.springframework.web.servlet.Dispat...
web.xml -
Tomcat常用配置
##server.xml``````##配置日志```#LicensedtotheApacheSoftwareFoundation(ASF)underoneormore#contributorlicenseagreements.SeetheNOTICEfiledistributedwith#thisworkforadditionalinformationregardingcopyrightownership.#TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0#(the"License");youmaynotusethisfileexceptincompliancewith#theLicense.YoumayobtainacopyoftheLicenseat##http://www.apache.org/licenses/LICENSE-2.0##Unlessrequiredbyapplicablelaworagreedtoinwriting,software#distributedundertheLicenseisdistributedon...
Tomcat -
systemd常用配置
配置`linux`服务`vi/etc/systemd/system/service.service`内容:```[Unit]Description=描述信息After=network.targetnetwork-online.targetWants=network.targetnetwork-online.target[Service]User=root#forking:本身就是后台进程Type=simple|forking|notifyKillMode=processExecStart=启动命令ExecReload=/bin/kill-HUP$MAINPIDExecStop=/bin/kill-QUIT$MAINPID#always:如果不是关闭自动重启Restart=no|always|on-failureRestartSec=5s[Install]WantedBy=multi-user.target```然后加载服务:```systemctldaemon-reload```配置里面所有命令需要使用完整路径,否者可能提示下面错误:```May0915:44:02acgistsystemd[1]:servi...
systemd -
Ehcache常用配置
``````
Ehcache