容器中jackson时间戳时区错误问题

场景:k8s部署springboot项目,发现返回时间戳时区是错的

我以为时间戳是统一的没有时区问题,还是理解的粗浅了

尝试过改节点时区,改容器时区,改spring.jackson.time-zone配置,都没效果

有效过的是main里运行 TimeZone.setDefault(TimeZone.getTimeZone(“Asia/Shanghai”));

win10多人远程登录

1、系统属性,开启远程桌面,添加远程桌面登录用户;

2、快捷键win+R,输入 gpedit.msc ,打开本地组策略编辑器。选择“【管理模板】—>【Windows组件】—>【远程桌面服务】—>【远程桌面会话主机】—>【连接】

配置【限制连接的数量】,点击“已启用”,其中允许的RD最大连接数可以自己视情况而定

配置【允许用户通过使用远程桌面服务进行远程连接】,选择启用。

配置【将远程桌面服务用户限制到单独的远程桌面服务会话】,选择启用:

3、快捷键win+R键,输入msconfig,选择安全模式,重启进入安全模式

4、安全模式下运行如下脚本:



    # PowerShell script used to patch termsrv.dll file and allow multiple RDP connections on Windows 10 (1809 and never) and Windows 11 
    # Details here http://woshub.com/how-to-allow-multiple-rdp-sessions-in-windows-10/
     
    # Stop RDP service, make a backup of the termsrv.dllfile and change the permissions 
    Stop-Service UmRdpService -Force
    Stop-Service TermService -Force
    $termsrv_dll_acl = Get-Acl c:\windows\system32\termsrv.dll
    Copy-Item c:\windows\system32\termsrv.dll c:\windows\system32\termsrv.dll.copy
    takeown /f c:\windows\system32\termsrv.dll
    $new_termsrv_dll_owner = (Get-Acl c:\windows\system32\termsrv.dll).owner
    cmd /c "icacls c:\windows\system32\termsrv.dll /Grant $($new_termsrv_dll_owner):F /C"
    # search for a pattern in termsrv.dll file 
    $dll_as_bytes = Get-Content c:\windows\system32\termsrv.dll -Raw -Encoding byte
    $dll_as_text = $dll_as_bytes.forEach('ToString', 'X2') -join ' '
    $patternregex = ([regex]'39 81 3C 06 00 00(\s\S\S){6}')
    $patch = 'B8 00 01 00 00 89 81 38 06 00 00 90'
    $checkPattern=Select-String -Pattern $patternregex -InputObject $dll_as_text
    If ($checkPattern -ne $null) {
        $dll_as_text_replaced = $dll_as_text -replace $patternregex, $patch
    }
    Elseif (Select-String -Pattern $patch -InputObject $dll_as_text) {
        Write-Output 'The termsrv.dll file is already patch, exitting'
        Exit
    }
    else { 
        Write-Output "Pattern not found "
    }
    # patching termsrv.dll
    [byte[]] $dll_as_bytes_replaced = -split $dll_as_text_replaced -replace '^', '0x'
    Set-Content c:\windows\system32\termsrv.dll.patched -Encoding Byte -Value $dll_as_bytes_replaced
    # comparing two files 
    fc.exe /b c:\windows\system32\termsrv.dll.patched c:\windows\system32\termsrv.dll
    # replacing the original termsrv.dll file 
    Copy-Item c:\windows\system32\termsrv.dll.patched c:\windows\system32\termsrv.dll -Force
    Set-Acl c:\windows\system32\termsrv.dll $termsrv_dll_acl
    Start-Service UmRdpService
    Start-Service TermService
原文链接:https://blog.csdn.net/luexon/article/details/125078585

记录一个docker升级docker-ce问题

老系统装的docker发现很多镜像已经不再支持,查网上需要装docker-ce,卸载docker,添加源:https://download.docker.com/linux/centos/docker-ce.repo。安装docker-ce最后启动docker报异常:

journalctl -xe
-- The start-up result is done.
Dec 08 17:30:01 iZbp1j6nqn3qz7t3ojr1ccZ systemd[1]: Starting Session 2097629 of user root.
-- Subject: Unit session-2097629.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-2097629.scope has begun starting up.
Dec 08 17:30:01 iZbp1j6nqn3qz7t3ojr1ccZ CROND[6511]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Dec 08 17:30:13 iZbp1j6nqn3qz7t3ojr1ccZ sshd[6516]: Invalid user ftpadmin from 47.96.36.95 port 39610
Dec 08 17:30:13 iZbp1j6nqn3qz7t3ojr1ccZ sshd[6516]: input_userauth_request: invalid user ftpadmin [preauth]
Dec 08 17:30:13 iZbp1j6nqn3qz7t3ojr1ccZ sshd[6516]: pam_unix(sshd:auth): check pass; user unknown
Dec 08 17:30:13 iZbp1j6nqn3qz7t3ojr1ccZ sshd[6516]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=47.96.36.95
Dec 08 17:30:15 iZbp1j6nqn3qz7t3ojr1ccZ sshd[6516]: Failed password for invalid user ftpadmin from 47.96.36.95 port 39610 ssh2
Dec 08 17:30:15 iZbp1j6nqn3qz7t3ojr1ccZ sshd[6516]: Received disconnect from 47.96.36.95 port 39610:11: Bye Bye [preauth]
Dec 08 17:30:15 iZbp1j6nqn3qz7t3ojr1ccZ sshd[6516]: Disconnected from 47.96.36.95 port 39610 [preauth]
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ polkitd[502]: Registered Authentication Agent for unix-process:6549:6800316710 (system bus name :1.4195603 [/usr/bin/pkttyagent --notify-fd 5 --fallback],
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ systemd[1]: Starting Docker Application Container Engine...
-- Subject: Unit docker.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has begun starting up.
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ dockerd[6555]: time="2023-12-08T17:31:08.763547319+08:00" level=info msg="Starting up"
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ dockerd[6555]: time="2023-12-08T17:31:08.798534673+08:00" level=error msg="[graphdriver] /var/lib/docker contains several valid graphdrivers: overlay2, de
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ dockerd[6555]: failed to start daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: overlay2, devicemapper; cleanu
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has failed.
-- 
-- The result is failed.
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ systemd[1]: Unit docker.service entered failed state.
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ systemd[1]: docker.service failed.
Dec 08 17:31:08 iZbp1j6nqn3qz7t3ojr1ccZ polkitd[502]: Unregistered Authentication Agent for unix-process:6549:6800316710 (system bus name :1.4195603, object path /org/freedesktop/PolicyKit1/Auth
Dec 08 17:31:11 iZbp1j6nqn3qz7t3ojr1ccZ systemd[1]: docker.service holdoff time over, scheduling restart.
Dec 08 17:31:11 iZbp1j6nqn3qz7t3ojr1ccZ systemd[1]: Starting Docker Application Container Engine...
-- Subject: Unit docker.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has begun starting up.

最后看到这个贴:https://zhuanlan.zhihu.com/p/660028084。

rm -rf /var/lib/docker/*
systemctl start docker

终于能启动了

vue使用tinymce本地加载方案2,更快加载tinymce

提下方案1:是改写tinymce-vue的script加载器,vue的tinymce-vue原来只是个script加载器, 改的地方略微多。

发现了另一个方法:
首先,不能再使用tinymce-vue,只用tinymce,好处是不需要api-key

npm install tinymce

同时将tinymce放到static目录用于引用css

js的部分用import
css的部分用tinymce.init

使用方式如下:

<script setup>
import {onMounted } from 'vue'
import tinymce from 'tinymce' //加载tinymce的js
import 'tinymce/themes/silver/theme' //加载theme
import 'tinymce/models/dom/model' //加载model
import 'tinymce/icons/default/icons' //加载icon

onMounted(() => {
    tinymce.init({
        selector: 'textarea#default', 
        skin_url: 'static/tinymce/skins/ui/oxide', 
        theme_url:'static/tinymce/themes/silver/theme',
        content_css:'static/tinymce/skins/ui/oxide/content.min.css'
    });
})
</script>

<template>
  <textarea id="default">Hello, World!</textarea>
</template>

Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: No classes have been predefined during the image build to load from bytecodes at runtime.

spirngboot项目,graalvm native 编译完成后运行服务运行报错,

Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: No classes have been predefined during the image build to load from bytecodes at runtime.

看帖子说是jdk版本问题,可我是用的graalvm编译的没错呀。后测试发现跟springboot版本有关,springboot3.1.0会报这个错,3.0.4和3.0.7测试过没问题

反序列化错误com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `***` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information

在junit中用jackson做反序列化的时候报错

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of *** (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information

原因是用了2个class继承一个interface,反序列化interface时无法找到用哪个class结果出了异常,网上能搜到的解决方法是写个配置类,如:@Bean注解创建ObjectMapper、重写configureMessageConverters方法。

发现了一个更简单的方式,是在属性中加@JsonDeserialize注解如:

//这里I是interface I2是I的实现类
@JsonDeserialize(contentAs=I2.class)
public interface I{
  Integer a;
}

这样Junit中的反序列化就能跑通了

发现个vue绑定boolean的小bug

测试用的版本为3.2.47

比如<div v-if=”state.myobj.isTrue”></div>

class myobj
{
isTrue:boolean
}

自定义了一个myobjd对象,里面有个isTrue,如果是boolean类型,通过改变isTrue=true或false是无法控制div是否显示的。

如果isTrue是个number类的,如<div v-if=”state.myobj.isTrue==1″></div>

class myobj
{
isTrue:number
}

然后通过state.myobj.isTrue=1或=0能控制div是否显示

不知是bug还是用法有问题

http-vue-loader是个好东西

需要写个简单的小项目,3个网页跳转,有些逻辑处理

想到了用vue,简单处理不用构建工具编译,创建了3个html,分别使用vue处理模板和逻辑显示,这时增加了个需求,有个悬停的音频播放按钮要贯穿3个页面,这要分开写,页面一跳转音频就停止了。

这时就需要一个能在html中加载多个vue模板的的功能,终于发现了:
http-vue-loader

官网github例子中主要是用作子组件和如何添加到当前页,实际使用时发现搭配vue-router也十分好用,跟使用构建工具没有什么大差别。

html中: 
const Question=httpVueLoader('question.vue')
  const routes = [
        { path: '/question', component: Question },
    ]

question.vue中:
<script>
    module.exports = {
        data() {
        ......
         }
    }
</script>

//唯一的使用差异可能也就是 module.exports  这里了

vue的tinymce-vue原来只是个script加载器

tinymce比较好用,自定义一些功能也很方便。使用中发现加载总是不是那么迅速,一开始以为性能就是这样的,通过加载记录发现tinymce中的js组件居然都是加载tinymce官网的资源,一直在访问外网能不慢么。

就想tinymce-vue是vue组件呀,都install进来了,怎么还在走外网呢?打开tinymce-vue包发现实际上就是个script加载器,使用tinymce-vue后,实际上不需要install tinymce也能运行,他会判断本地是否有tinymce环境,没有的话,就直接创建script标签加载网页版本的js文件,再使用普通网页的方式初始化tinymce组件。

方式A:解决方式是把tinymce-vue中scriptloader复制到本地再改下js路径,把tinymce资源放到自己的服务器,这样就快多了。不再需要api-key。仿照tinymce-vue的写法,如:

//ScriptLoader_1需要到tinymce-vue中找,
ScriptLoader_1.ScriptLoader.load(document,'//a.com(自己的服务器)/tinymce.min.js',function () {
     that.tinymce=tinymce
     that.editor=that.tinymce.init(that.tinymceConfig)
     const formatpainter= import('tinymce-plugin-formatpainter')
})

方式B:增加资源路径,把部分资源放在自己的服务器,无需修改代码,易燃依赖tinymce-vue和需要api-key,能提高一点速度,但不彻底,如:

<Editor
          api-key="no-api-key"
          :init="{
        plugins: 'lists link image table code help wordcount',
        skin_url: '/node_modules/tinymce/skins/ui/oxide',
        theme_url:'/node_modules/tinymce/themes/silver/theme',
        icons_url:'/node_modules/tinymce/icons/default/icons.js',
        model_url:'/node_modules/tinymce/models/dom/model.min.js',

      }"
  />