1、问题1-Uncaught (in promise) TypeError: Cannot read property ‘xx’ of null
1、问题描述
今天在测试将数据保存到ES中时,在“发布商品”时,下面图像内容无法显示:
前端也能从后台拿到相应的数据,前端会有下面的报错信息:
ncaught (in promise) TypeError: Cannot read property 'xx' of null
定位到,是D:\03Enviroment\28VSCode\code\renren-fast-vue\src\views\modules\product\spuadd.vue
文件中的代码:
showBaseAttrs() {
if (!this.dataResp.steped[0]) {
this.$http({
url: this.$http.adornUrl(
`/product/attrgroup/${this.spu.catalogId}/withattr`
),
method: "get",
params: this.$http.adornParams({})
}).then(({ data }) => {
//先对表单的baseAttrs进行初始化
data.data.forEach(item => {
console.log("item---",item)
console.log("item.attrs---",item.attrs)
console.log("item.attrs.attrId---",item.attrs.attrId)
let attrArray = [];
item.attrs.forEach(attr => {
console.log("进入attr.attrId---",attr.attrId)
attrArray.push({
attrId: attr.attrId,
attrValues: "",
showDesc: attr.showDesc
});
});
this.dataResp.baseAttrs.push(attrArray);
});
this.dataResp.steped[0] = 0;
this.dataResp.attrGroups = data.data;
});
}
},
2、解决
在属性分组中,主体和基本信息已经将规格参数信息关联完:
假如我们新增一个属性分组屏幕
,其没有和任何规格参数关联,当在“发布商品”的时候,进入到新增规格参数一栏,前端给后端发送请求,后端将携带数据返回,但是后端中的屏幕
分组attrs
没有相关联的规格信息,在上面的前端代码的遍历中就会报错。返回数据格式如下:
{
"msg":"success",
"code":0,
"data":[
{
"attrGroupId":1,
"attrGroupName":"主体",
"sort":null,
"descript":null,
"icon":null,
"catelogId":225,
"attrs":[
{
"attrId":13,
"attrName":"入网型号",
"searchType":1,
"icon":"xx",
"valueSelect":"A01;B01",
"attrType":1,
"enable":1,
"catelogId":225,
"showDesc":0,
"valueType":1
},
{
"attrId":14,
"attrName":"上市年份",
"searchType":1,
"icon":"xx",
"valueSelect":"2018;2019",
"attrType":1,
"enable":1,
"catelogId":225,
"showDesc":0,
"valueType":0
}
]
},
{
"attrGroupId":2,
"attrGroupName":"基本信息",
"sort":null,
"descript":null,
"icon":null,
"catelogId":225,
"attrs":[
{
"attrId":17,
"attrName":"机身颜色",
"searchType":1,
"icon":"xx",
"valueSelect":"朱红色;小米色",
"attrType":1,
"enable":1,
"catelogId":225,
"showDesc":0,
"valueType":1
},
{
"attrId":18,
"attrName":"机身长度",
"searchType":1,
"icon":"xx",
"valueSelect":"10;20",
"attrType":1,
"enable":1,
"catelogId":225,
"showDesc":0,
"valueType":0
}
]
},
{
"attrGroupId":3,
"attrGroupName":"屏幕",
"sort":0,
"descript":"屏幕",
"icon":"xxx",
"catelogId":225,
"attrs":null
}
]
}
将没有关联信息的属性分组屏幕
删除即可。
2、问题2- Invalid bound statement (not found)
1、问题描述
在学习谷粒商城“商品详情”时,遇到了mybatis的dao接口绑定失效问题:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xiaolun.gulimall.product.dao.AttrGroupDao.getAttrGroupWithAttrsBySpuId
经过检查,对应的接口都能跳转,发现时target的问题,如下:
当我对gulimall-product
项目进行clear后,生成的dao.xml文件就剩下面的四个:
这说明不是代码的问题,是idea的问题。
2、解决方法
在pom文件中引入下面的配置:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
3、问题3- Data truncation: Data too long for column ‘order_sn’ at row 1
1、问题描述
在进行提交订单操作时,如下图:
弹出下面的错误:
Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'order_sn' at row 1
2、解决
修改数据库中对应订单的字段长度:
4、问题4
1、问题描述
在测试代码中的支付逻辑时,为了保持简洁性,我将数据库中关于订单和库存(oms_order、wms_ware_order_task、wms_ware_order_task_detail
)的数据全部删除进行测试,然而,在gulimall-ware
服务的控制台中一直打印
收到解锁库存的消息
一些sql语句
将yml配置文件中调试配置关闭:
# 用来查看逻辑删除的sql语句
logging:
level:
com.xiaolun.gulimall.ware: debug
sql语句没有了,但是还是会收到“收到解锁库存的消息”这句话,通过查看RabbitMq,发现里面一直有一个未消费的消息:
2、解决
将gulimall-ware
服务停掉,将消息删除后,重启该服务就没有出现这样的问题了。
应该时将数据表删除之后,上面解锁逻辑查询数据库失败,无法解锁,抛出异常,然后队列重新入队,再次消费引起的。
5、问题5-前后端时间不同步问题
1、SpringBoot 查询时间数据 数据库和返回数据相差8个小时,或者+0800/T等
由于本项目中使用到了fastjson,所以对其进行下面的配置:
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
2、使用Vue向后端发送数据无法接收
(1)介绍
按照上面添加时区配置后,进行下面的更新秒杀时间操作:
发现前端传的的时间格式和后端的时间格式不一样,导致后台无法接收,产生警告信息。前端传递的是UTC格式的,类似于下面这种:
2020-03-09T16:00:00.000Z
这样的格式,后端无法处理,后端代码为:
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody SeckillSessionEntity seckillSession){
seckillSessionService.updateById(seckillSession);
return R.ok();
}
(2)解决
参考博客:
https://www.freesion.com/article/5355374455/
https://www.jianshu.com/p/e28783ab43f8
全局安装时间格式化器moment
npm install moment -s
在入口文件main.js中全局配置时间格式化器moment
// 前端代码传递给后端时间问题修改
import moment from 'moment'
//添加到Vue实例中以便全局使用
Vue.prototype.$moment = moment;
使用,不用在vue组件中引入moment,使用this.$moment
使用
this.xx=this.$moment(this.xx).format('YYYY-MM-DD HH:mm:ss');
谷粒商城优惠秒杀服务代码(相对路径:src\views\modules\coupon\seckillsession-add-or-update.vue
):
// 表单提交
dataFormSubmit() {
this.$refs["dataForm"].validate(valid => {
if (valid) {
this.$http({
url: this.$http.adornUrl(
`/coupon/seckillsession/${!this.dataForm.id ? "save" : "update"}`
),
method: "post",
data: this.$http.adornData({
id: this.dataForm.id || undefined,
name: this.dataForm.name,
// startTime: this.dataForm.startTime,
// endTime: this.dataForm.endTime,
startTime: this.$moment(this.dataForm.startTime).format('YYYY-MM-DD HH:mm:ss'),
endTime: this.$moment(this.dataForm.endTime).format('YYYY-MM-DD HH:mm:ss'),
status: this.dataForm.status,
// createTime: new Date()
createTime: this.$moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
})
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.visible = false;
this.$emit("refreshDataList");
}
});
} else {
this.$message.error(data.msg);
}
});
}
});
}
此时,发送请求参数如下,时间按照对应格式发送给后端:
6、问题6-kubernetes安装遇到的问题
1、master节点初始化报错
1、问题描述
在node1、node2、node3三个虚拟机上安装安装kubeadm,kubelet和kubectl后,执行master(node1)节点初始化,在VirtualBox创建的三台虚拟机上使用下面指令,能够正常执行:
# apiserver-advertise-address对应的是master节点中的eth0地址
kubeadm init \
--apiserver-advertise-address=10.0.2.15 \
--image-repository registry.cn-hangzhou.aliyuncs.com/google_containers \
--kubernetes-version v1.17.3 \
--service-cidr=10.96.0.0/16 \
--pod-network-cidr=10.244.0.0/16
在阿里云ECS服务器上,使用相同的指令执行:
# 此时,apiserver-advertise-address对应的是ECS上的公网ip
kubeadm init \
--apiserver-advertise-address=47.118.33.234 \
--image-repository registry.cn-hangzhou.aliyuncs.com/google_containers \
--kubernetes-version v1.17.3 \
--service-cidr=10.96.0.0/16 \
--pod-network-cidr=10.244.0.0/16
通过日志查看,发现master节点的初始化构建过程会卡顿在这里,并报错:
2、解决
将初始化命令中的下面语句进行删除:
--apiserver-advertise-address=47.118.33.234 \
发现可以正常执行,并生成了下面的在其他节点添加进而构成kubernetes网络的信息:
kubeadm join 172.26.147.202:6443 --token lphkhi.ptkgscmikv0qbuiu \
--discovery-token-ca-cert-hash sha256:c8f278bcb1e55ca9ac8466e326189ea3f42241097409090b124a80187ce689e4
172.26.147.202:6443
该网址对应的阿里云服务器上公网ip47.118.33.234
地址,也是eth0
地址。
要访问阿里云服务器,记得要开启相关安全组端口。
2、ECS相关配置
1、操作
(1)开放的端口
(2)nodes名字
(3)启动的服务和应用
3、最小化安装kubesphere报错
1、描述
在安装kubesphere2.1(kubernetesv1.7.3)时,在使用 kubesphere-minimal.yaml
或 kubesphere-complete-setup.yaml
安装时,发现文件无法找到,我就使用了kubesphere3.0.0的安装文件:
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/kubesphere-installer.yaml
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/cluster-configuration.yaml
虽然说kubesphere
可以运行,但是在使用helm
指令安装sonar-qube
可拔插插件时,Helm
需要选用3版本,命令如下:
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
helm upgrade --install sonarqube sonarqube --repo https://charts.kubesphere.io/main -n kubesphere-devops-system --create-namespace --set service.type=NodePort
参考网址:
https://kubesphere.com.cn/docs/devops-user-guide/how-to-integrate/sonarqube/#%e4%b8%ba%e6%96%b0%e5%b7%a5%e7%a8%8b%e5%88%9b%e5%bb%ba-sonarqube-token
但是,安装kubesphere2.1的Helm
是版本v2.16.3
,导致上面命令不可用而报错,加入将Helm
版本升级到版本3,但是又和kubesphere2.1版本不兼容,因此,推荐使用kubesphere2.1
安装,需要找到最小化安装文件 kubesphere-minimal.yaml
或 kubesphere-complete-setup.yaml
,我将其上传到csdn的资源中心了,供大家下载,路径地址为:
https://download.csdn.net/download/weixin_43334389/18110072
内容如下:
---
apiVersion: v1
kind: Namespace
metadata:
name: kubesphere-system
---
apiVersion: v1
data:
ks-config.yaml: |
---
persistence:
storageClass: ""
etcd:
monitoring: False
endpointIps: 192.168.0.7,192.168.0.8,192.168.0.9
port: 2379
tlsEnable: True
common:
mysqlVolumeSize: 20Gi
minioVolumeSize: 20Gi
etcdVolumeSize: 20Gi
openldapVolumeSize: 2Gi
redisVolumSize: 2Gi
metrics_server:
enabled: False
console:
enableMultiLogin: False # enable/disable multi login
port: 30880
monitoring:
prometheusReplicas: 1
prometheusMemoryRequest: 400Mi
prometheusVolumeSize: 20Gi
grafana:
enabled: False
logging:
enabled: False
elasticsearchMasterReplicas: 1
elasticsearchDataReplicas: 1
logsidecarReplicas: 2
elasticsearchMasterVolumeSize: 4Gi
elasticsearchDataVolumeSize: 20Gi
logMaxAge: 7
elkPrefix: logstash
containersLogMountedPath: ""
kibana:
enabled: False
openpitrix:
enabled: False
devops:
enabled: False
jenkinsMemoryLim: 2Gi
jenkinsMemoryReq: 1500Mi
jenkinsVolumeSize: 8Gi
jenkinsJavaOpts_Xms: 512m
jenkinsJavaOpts_Xmx: 512m
jenkinsJavaOpts_MaxRAM: 2g
sonarqube:
enabled: False
postgresqlVolumeSize: 8Gi
servicemesh:
enabled: False
notification:
enabled: False
alerting:
enabled: False
kind: ConfigMap
metadata:
name: ks-installer
namespace: kubesphere-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: ks-installer
namespace: kubesphere-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: ks-installer
rules:
- apiGroups:
- ""
resources:
- '*'
verbs:
- '*'
- apiGroups:
- apps
resources:
- '*'
verbs:
- '*'
- apiGroups:
- extensions
resources:
- '*'
verbs:
- '*'
- apiGroups:
- batch
resources:
- '*'
verbs:
- '*'
- apiGroups:
- rbac.authorization.k8s.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- apiregistration.k8s.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- apiextensions.k8s.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- tenant.kubesphere.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- certificates.k8s.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- devops.kubesphere.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- monitoring.coreos.com
resources:
- '*'
verbs:
- '*'
- apiGroups:
- logging.kubesphere.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- jaegertracing.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- storage.k8s.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- admissionregistration.k8s.io
resources:
- '*'
verbs:
- '*'
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: ks-installer
subjects:
- kind: ServiceAccount
name: ks-installer
namespace: kubesphere-system
roleRef:
kind: ClusterRole
name: ks-installer
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ks-installer
namespace: kubesphere-system
labels:
app: ks-install
spec:
replicas: 1
selector:
matchLabels:
app: ks-install
template:
metadata:
labels:
app: ks-install
spec:
serviceAccountName: ks-installer
containers:
- name: installer
image: kubesphere/ks-installer:v2.1.1
imagePullPolicy: "Always"
4、sonarqube配置
1、操作
kubesphere2.1版本有一个内置的sonarqube,按照文档,在创建凭证的时候十分方便,参考网址如下:
https://v2-1.docs.kubesphere.io/docs/zh-CN/devops/sonarqube/
通过下面的指令,找到运行的sonarqube服务:
kubectl get svc --all-namespaces
可以看到该服务运行的端口号,阿里云服务器中开启对这个端口的访问,参考上面的网址使用admin/admin
进入sonarqube进行配置就可以了,配置如下:
将图中的凭证配置成流水线的秘密文本就可以了:
15e8e389ba4921124076e6bc44d454ec14f6b142
7、问题七-流水线问题
1、推送镜像到阿里云速度慢
1、问题描述
使用流水线打成jar包和使用Dockerfile
文件将jar包打成镜像推送到阿里云速度很慢,当服务器运行负荷比较大的时候,推送速度只有40kB/s,然后镜像有700MB,这需要猴年马月。
我还特意测了一下阿里云的镜像加速器,发现不是它的原因。
2、问题解决
主要是我的阿里云服务器使用的是固定带宽1Mb/S,带宽太小了,需要增大带宽10Mb/S,如下:
此时,推送速度很快,大约5-7分钟的样子。
2、创建镜像仓库密钥中文不能识别报错
1、问题描述及解决
将镜像推送到阿里云之后,配置一个镜像仓库密钥来拉取镜像,但是会遇到下面的问题:
在阿里云无法进行修改,对其进行 urlencode
编码,可通过一些第三方网站进行转换,网址:
http://tool.chinaz.com/tools/urlencode.aspx
还是无法进行修改,只能重新申请一个账号。
注意:仓库地址采用HTTPS
协议进行验证,否则无法识别,导致镜像仓库密钥无法创建。
3、镜像部署到k8s异常
1、问题-unprocess entity
(1)描述
当流水线运行拉取代码、代码质量检查、构建和推送镜像,到运行到部署到k8s时,会有下面的报错:unprocess entity
:
30861: provided port is already allocated
(2)解决
通过检查deploy部署文件gulimall-gateway-deploy-svc.yaml
,如下:
apiVersion: v1
kind: Service
metadata:
labels:
app: gulimall-gateway
component: gulimall-gateway
name: gulimall-gateway
namespace: gulimall
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
nodePort: 30861
selector:
app: gulimall-gateway
component: gulimall-gateway
tier: backend
sessionAffinity: None
type: NodePort
发现该service
使用的端口为30861,在kubesphere2.1的快速入门-基于Spring Boot构建流水线中,我发现其运行的端口也是30861:
将该容器停掉即可。
注意:Service
的nodeport端口范围:30000-32767。
2、容器OOMkill异常
(1)描述
运行流水线部署到k8s中的项目,容器启动会报OOM错误,如下:
(2)解决
在部署的时候,内存最大限制为600mi,cpu限制0.3核,gulimall-gateway-deploy.yaml
文件内容如下:
resources:
limits:
cpu: 300m
memory: 600Mi
然而,服务启动的时候,jvm一次性给其分配内存为几个G,超出容器限制,会被kubesphere杀掉,进而导致容器被停掉。
在构建docker镜像的时候,添加占用内存配置:"-Xms128m","-Xmx300m"
,Dockerfile
内容如下:
ENTRYPOINT ["java","-jar","-Xms128m","-Xmx300m","/app.jar","--spring.profiles.active=prod"]
经过这样的配置gulimall-gateway服务不会出现这样的OOM问题,但是会发现容器会有容器没有准备就绪
的状态,打开日志会有这样的内容:
但是会发现gulimall-gateway
服务已经成功注册到nacos
中了,
3、环境变量无法识别
(1)问题描述
在运行流水线时,输入项目名,一遍在审核的时候可以动态取值,然后在运行到将镜像推送到k8s集群中时,发现无法动态取值。
(2)解决
将单引号’‘变成双引号“”,以便环境变量$PROJECT_NAME
可以生效:
stage('5-deploy to dev-部署到k8s') {
when{
branch 'master'
}
steps {
sh 'echo $PROJECT_NAME'
input(id: 'deploy-to-dev-$PROJECT_NAME', message: "deploy to dev-是否将 $PROJECT_NAME 部署到集群中?")
kubernetesDeploy(configs: "$PROJECT_NAME/deploy/**", enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
4、Readiness probe failed
1、问题描述
在将gulimall-gateway项目使用流水线上传到k8s时,流水线是执行成功的,如下图所示:
但是这并不意味着容器在k8s中会部署成功。容器在部署过程中会遇到这个问题:
Readiness probe failed: Get http://10.244.0.88:8080/: dial tcp 10.244.0.88:8
使用下面指令查看该pod的运行状况,和报错信息一样,如下图所示:
kubectl describe pod gulimall-gateway-7644cdcd48-4xg8v(pod名) -n gulimall(namespaces)
2、解决
该问题是部署文件的问题,不是jenkinsfile文件的问题,通过查看部署文件gulimall-gateway-deploy.yaml
,看到和指针相关的内容如下:
spec:
containers:
- env:
- name: CACHE_IGNORE
value: js|html
- name: CACHE_PUBLIC_EXPIRATION
value: 3d
image: $REGISTRY/$ALIYUN_NAMESPACE/$PROJECT_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER
readinessProbe:
httpGet:
path: /
port: 8080
timeoutSeconds: 60
failureThreshold: 30
periodSeconds: 5
通过查阅相关博客:
https://cloud.tencent.com/developer/article/1386151
https://www.cnblogs.com/xuewenlong/p/13322787.html
应该是服务在启动期间就对其进行检查,由于该应用没有处于就绪状态,会被标记为unhealty
状态,因此,将其注释,即不进行readinessProbe
检查或者使用k8s集群自带检查即可:
spec:
containers:
- env:
- name: CACHE_IGNORE
value: js|html
- name: CACHE_PUBLIC_EXPIRATION
value: 3d
image: $REGISTRY/$ALIYUN_NAMESPACE/$PROJECT_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER
# readinessProbe:
# httpGet:
# path: /
# port: 8080
# timeoutSeconds: 60
# failureThreshold: 30
# periodSeconds: 5
此时,查看pod运行状况:
5、service无法部署
1、问题描述及解决
在运行流水线部署的时候,在部署到k8s时,会遇到一些service无法部署的问题,主要原因是,在service部署文件中,包含有项目的部署信息,比如:
apiVersion: v1
kind: Service
metadata:
labels:
app: kubesphere
component: ks-sample-dev
name: ks-sample-dev
namespace: kubesphere-sample-dev
service会部署到 kubesphere-sample-dev
这个项目 (Namespace) 环境中,该项目需要预先在控制台依次创建,对应下面内容:
6、sonar代码质量分析报错
1、问题描述
在运行实例代码时,sonar质量分析时会报出下面的错误:
2、解决
这个报错主要是springboot的版本太低导致的,我们到springboot官方文档中,找一个稳定的版本即可,比如2.1.13.RELEASE
的:
7、访问vue前端报跨域请求错误
1、问题描述
在本地IDEA调试好代码后,放到阿里云进行访问,报出下面的跨域请求错误:
但是login
请求是正确的,返回状态码200。
2、解决
返回两个http请求,这说明在后端添加解决跨域请求配置后,在前端也有一个配置,但是我已经将前端的核心代码配置进行注释了,但是我并没有完全注释,将其完全注释就可以了:
8、配置nginx指定访问路径失败
1、问题描述
参考博客:
https://blog.csdn.net/medivhq/article/details/72628782
https://blog.csdn.net/weixin_39592623/article/details/91039525
使用下面的命令前端vue文件的镜像进行打包:
FROM nginx
MAINTAINER leifengyang
# 将静态资源放到nginx中,可以直接访问
ADD dist.tar.gz /usr/share/nginx/html
EXPOSE 80
ENTRYPOINT nginx -g "daemon off;"
k8s拉取该镜像进行部署,我按照ip地址的方式进行访问该前端项目,未能弹出前端界面按照下面的方式可以进行访问:
ip/dist/index.html
修改配置文件conf.d/default.conf:
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html/dist;
index index.html;
}
按照ip地址进行访问,发现还是不能生效,在docker中,我会重启容器,但是在k8s中,修改配置文件后,没有重启该容器。
2、解决
修改打包镜像的Dockerfile文件,在打包的时候就进行修改配置文件:
FROM nginx
MAINTAINER leifengyang
ADD dist.tar.gz /usr/share/nginx/html
COPY default.conf /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
ENTRYPOINT nginx -g "daemon off;"
那么镜像就会使用我们的配置进行启动容器。使用ip进行测试,可以正常访问前端。
9、启动gulimall-product服务报出Failed to configure a DataSource url attribute is not specified
1、问题描述
参考博客:
https://blog.csdn.net/qq_42397121/article/details/106845656
https://blog.csdn.net/u013887008/article/details/105447036
在书写product
服务时,运行该服务会出现该target包中没有mapper
相关xml
文件的报错,k8s运行到阿里云的时候,发现连yml、application和template/xx.html等相关文件都没有了。
2、解决
无法扫描配置,启动出错,在pom文件中添加下面的配置下面的配置:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.html</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
如果没有maven-plugin插件,会报出下面的错误:
boot-package no main manifest attribute, in /app.jar
8、Docker中配置Redis连接不上
1、问题描述
在Docker上安装redis(5.0.12),redis是按照指定文件conf启动的,在本机上也可以访问,在配置文件中将bind 127.0.0.1
中改成了bind 0.0.0.0
,但是,在IDEA中进行连接redis时,会有下面的报错:
redis.clients.jedis.exceptions.JedisConnectionException: Could not get xx
使用docker ps
命令查看redis的启动状况,发现redis没有正常启动。
2、解决
需要将daemonize
设置成No
,此时,才可以正常启动。
参考博客:
https://blog.csdn.net/lcyaiym/article/details/76863802
9、Vscode中将前端代码上传到gitee
1、步骤
参考博客:
https://blog.csdn.net/qq_36375203/article/details/98476758
(1)在码云上创建空白仓库
(2)点击源代码管理
初始化使用vscode打开的文件夹仓库
(3)点击上文的加号添加代码
(4)点击对号提交代码
(5)推动到远程仓库
其间需要输入远程仓库的地址和名字。如果遇到什么问题,可以通过下面的日志进行查看: