开发时遇到错误时的解决方案

1.KingbaseES时间类数据类型和oracle时间类数据类型的区别:

1
2
3
4
5
6
7
8
9
10
11
12
13
问题:人大金仓date 类型只保存日期,不保存时分秒。

解决方案:

1.使用 timestamp(6) without time zone
例如:
CREATE TABLE INS_TASK_TURN (
"EXECUTEDATE" timestamp(6) without time zone,
"CREATEDATE" timestamp(6) without time zone
);
2.修改库的模式为oracle模式不用PG模式
3.使用人大金仓的工具创建表,人大金仓自动把date类型转成了timestamp类型
4.迁移数据的时候,如果表为空数据,人大金仓不会自动把date类型转timestamp类型

2.golang编译安卓时发生报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
问题:编译时发送not found https://mirrors.aliyun.com/goproxy/gioui.org/cmd/@v/v0.0.0-20210925100615-41f3a7e74ee6.zip: 404 Not Found

解决方案:

#环境变量
#linux
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
#win
set GO111MODULE=on
set GOPROXY=https://goproxy.cn

#go env 设置(跨平台)
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn

3.maven打包时报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
报错:
repackage (default) on project nacos-console: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.1.2:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.1.2' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/springframe work/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

排查发现是maven-plugin 更新了3.1.2版本
报错时用的plugin:
<plugin>    
<groupId>org.springframework.boot</groupId>    
<artifactId>spring-boot-maven-plugin</artifactId>    
<configuration>        
<mainClass>com.alibaba.nacos.Nacos</mainClass>        
<layout>ZIP</layout>    
</configuration>    
<executions>        
<execution>              
<goals>                
<goal>repackage</goal>              
</goals>          
</execution>    
</executions></plugin>

解决方案:降低版本,加上version,就可以正常打包了,例如:
<plugin>    
<groupId>org.springframework.boot</groupId>    
<artifactId>spring-boot-maven-plugin</artifactId>    
<version>2.6.4</version>    
<configuration>        
<mainClass>com.alibaba.nacos.Nacos</mainClass>        
<layout>ZIP</layout>    
</configuration>    
<executions>        
<execution>              
<goals>                
<goal>repackage</goal>              
</goals>          
</execution>    
</executions>
</plugin>

4.在linux上运行sh文件提示坏的解释器: 没有那个文件或目录解决

1
2
3
4
5
6
7
8
9
10
问题原因:

当我们在window下编写脚本然后在上传到Linux上时,由于window上换行显示的为\n\r,然而在linux上换行显示应该为\n,所以在Linux下无法读取从window上传来的脚本

问题解决:

将\r替换成空,即如下:

#/data/www/myblog/curl.sh表示你的脚本文件
sed -i 's/\r$//' /data/www/myblog/curl.sh

5.按方向键出来2468

1
2
3
4
5
键盘右侧小键盘是可以独立开启或者关闭的,在关闭状态中,只有2468和符号键可用。其中2468作为方向键上下左右使用。如果想要恢复它们的数字功能,开启数字小键盘即可。

解决:
开启右侧数字键的方法:
点击一下数字键左上角的“NumLock”即可。

6.定时任务Cron expression must consist of 6 fields (found 7 in “0 0 3* * 6L ?”)

1
2
3
4
5
6
7
Cron expression must consist of 6 fields (found 7 in "0 0 3* * 6L ?")

问题原因:
自从Spring3.0的版本后,cron表达式只能支持6个字段,也就是不支持年份的表达式

解决办法:
Spring 的 Scheduled 没办法指定年份,如果需要年份的话可以集成quartz

7.怎样删除oracle约束

1
2
3
4
5
6
删除主键约束
ALTER TABLE "YW_SJDJB" DROP "PK_YW_SJDJB_CASENUM"
有命名约束
ALTER TABLE "YW_SJDJB" DROP constraint "PK_YW_SJDJB_CASENUM"
查找无命名主键
Select * from user_constraints

8.HTTP?? 404 - ???

1
路由对应文件大小写问题

9.Job for tomcat.service failed because the control process exited with error code. See “systemctl status tomcat.service” and “journalctl -xe” for details.

1
2
3
4
1.使用systemctl status tomcat.service命令查看报错信息
2.报错提示说是缺少JAVA_HOME或JRE_HOME环境变量,就算在/etc/profile下配置了,tomcat也加载不到,这时要在tomcat的bin下找到一个名为setclasspath.sh的文件
3.tomcat启动的大致流程是startup.sh->catalina.sh->setclasspath.sh,而setclasspath.sh的作用就是加载环境变量
4.行的第一句就是去加载环境变量,所以需要在最前面加入JAVA_HOME

10.Error running ‘FormApplication’: Command line is too long. Shorten command line for FormApplication or also for Spring Boot default configuration?

1
默认的Shorten command line的值 改为 classpath file

11.SSL certificate problem: self signed certificate in certificate chain

1
2
3
打开Git Bash运行如下命令
export GIT_SSL_NO_VERIFY=true
git config --global http.sslVerify "false"

12.小程序上传代码上传报错Error: 系统错误,错误码:80051,source size 3298KB exceed max limit 2MB

1
2
3
点开微信开发者工具右上角详情,勾选以下两个
1.将js编译成es5
2.上传代码时自动压缩脚本文件

13.java 调用 Cannot run program “python”: CreateProcess error=2, 系统找不到指定的文件

1
2
3
1.原因是idea 不会直接去调用cmd的python环境变量,所以要自己设置
2.在idea 里的点击edit configurations
3.打开应用(RootAutoOperation) 在Environment variables 中填入python的路径例如 PATH=D:\pyhon\python

14.【cmd/Python】【编码错误】UnicodeEncodeError: ‘gbk’ codec can’t encode character ‘\U0001f602’ in position

1
2
3
4
5
6
7
8
9
10
11
12
13
解决方法一:(不生效)
1.原因是因为调用cmd去跑代码用的是cmd的gbk编码,print会出错
2.cmd命令行输入 chcp 输出显示:活动代码页:936代表是gbk编码65001代表utf-8编码
3.解决办法:
永久修改,修改注册表。
在运行中输入"regedit",找到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
然后“右键-新建”,
选择“字符串值”,
“名称”列填写“autorun”, 数值数据填写“chcp 65001” (注意有空格)
解决方案二:(生效)
import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

15. tomcat 配置通用的nacos 配置, 就是在多项目打包中经常改nacos配置,所以在每个现场服务器增加对应配置,来避免这些问题

1
就是在tomcat 中的config目录增加bootstrap.yml 文件

16. tomcat 启动,读取nacos 配置,报错,Caused by: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [int] for value ‘${sfs.redis.database}’; nested exception is java.lang.NumberFormatException: For input string: “${sfs.redis.database}”

1
2
3
4
在1.后面增加2
1.set "JAVA_OPTS=%JAVA_OPTS% -Djava.protocol.handler.pkgs=org.apache.catalina.webresources"

2.set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG% -Dfile.encoding=UTF-8"

17.docker拉取镜像,提示“Error response from daemon: Get ‘https://registry-1.docker.io/v2/’”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/etc/docker/daemon.json 改成或增加下面的内容:

{
"registry-mirrors": ["https://docker-cf.registry.cyou",
"https://docker.jsdelivr.fyi",
"https://docker.rainbond.cc",
"https://docker.registry.cyou",
"https://dockertest.jsdelivr.fyi",
"https://mirror.aliyuncs.com",
"https://dockercf.jsdelivr.fyi",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://mirror.iscas.ac.cn"]
}

重启docker服务:sudo systemctl daemon-reload && sudo systemctl restart docker

开发时遇到错误时的解决方案
http://example.com/2025/04/03/开发时遇到错误时的解决方案/
作者
zgx
发布于
2025年4月3日
许可协议