开发问题收集及知识点

一、idea

1.pom.xml爆红

选了type为:maven,依赖仅spring web;

1
2
3
4
Could not find artifact org.springframework.boot:spring-boot-starter-parent:pom:3.1.2.RELEASE in central (https://repo.maven.apache.org/maven2)

Project 'org.springframework.boot:spring-boot-starter-parent:3.1.2.RELEASE' not found

但是嘞,依旧没成功

1
No archetype found in remote catalog. Defaulting to internal catalog
1
unable to reload maven project

好好好,这么玩是吧

百度了之后,发现,我的IDEA是2020版本,而maven是3.8,算是最新版本,可能会出现不兼容情况

将环境变量路径改一下,然后maven设置改一下低版本的,重启下IDEA即可

1
expected START_TAG or END_TAG not TEXT (position: TEXT seen ...</dependency>\r\n\r\n !---\u90ae\u4ef6\u53d1\u9001-->\r\n <d... @57:5)

看看</dependency>标签有没有多余空格,换行有问题,格式之类的,注释的尖括号丢没丢之类的

所以内容是没问题,但多半是格式问题出错了

1
Could not transfer artifact org.springframework.boot:spring-boot-starter-data-redis:pom:${springboot. version} from/to alimaven

这个提示依旧很明显了,找到位置,将空格去掉

还剩下几个依赖确实安装不上

移动到project这个标签上,查看具体情况

反正,我还是有字符和括号的问题,删删改改就行了。最终完成了。

总结

1.IDEA版本与maven版本是否兼容

2.pom.xml文件中内容格式是否正确(标签是区分大小写的哈、符号啊、空格啊该删删,该改改)

2.maven依赖全红

刚处理完问题1,蹦出来这个

好好好

第二天打开,reload了maven,是好的

3.jrebel热部署

对idea.properties文件设置后,打开idea

1
2
3
4
5
6
7
8
9
he IDE cannot create the directory.
Possible reason: parent directory is read-only or the user lacks necessary permissions.

If you have modified the 'idea.config.path' property, please make sure it is correct,
otherwise, please re-install the IDE.

-----
Location: C:\Program Files\JetBrains\.IntelliJ IDEA 2020.1.2\config
java.nio.file.AccessDeniedException: C:\Program Files\JetBrains\.IntelliJ IDEA 2020.1.2

要管理员方式打开

将解压得到的jrebel放入生成的.JetBrains\.IntelliJ IDEA 2020.1.2\plugins

之后打开的idea就可以使用

激活jrebel ↓

https://blog.csdn.net/zhuzbYR/article/details/111460716

4.jrebel debug

Disconnected from the target VM, address: ‘127.0.0.1:64680’, transport: ‘socket’

法1:netstat -ano|findstr xxxx

如果没有端口占用,不会显示;

如果该端口被占用,会有至少一个连接信息,一般找到是LISTENING的网络连接以及其后一列的进程号PID。
使用命令:tasklist|findstr 你找到的PID,从进程列表中查找包含指定字符串的进程。
使用命令:taskkill /pid 你找到的PID -f,根据PID杀死进程

启动的VM参数太小导致JRebel检测不通过,直接终止本次启动,所以在Server config中补充VM Options即可

help->edit custom vm-> 将参数改大点,比如我的VM options -Djava.awt.headless=true -Xms2048m -Xmx2048m,但是没用

与防火墙也没有关系

通过在logback中设置一下,打印出debug信息

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-08-18 14:01:07 [ERROR][org.springframework.boot.SpringApplication][reportFailure][819] - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [com/cxs/allmodel/mapper]'; nested exception is java.io.FileNotFoundException: class path resource [com/cxs/allmodel/mapper] cannot be opened because it does not exist
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:583)
at org.springframework.context.support.AbstractApplicationContext.jrLockAndRefresh(AbstractApplicationContext.java:41002)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:42008)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
at com.easypan.Easypanapplication.main(Easypanapplication.java:16)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [com/cxs/allmodel/mapper]'; nested exception is java.io.FileNotFoundException: class path resource [com/cxs/allmodel/mapper] cannot be opened because it does not exist
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
... 21 common frames omitted
Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [com/cxs/allmodel/mapper]'; nested exception is java.io.FileNotFoundException: class path resource [com/cxs/allmodel/mapper] cannot be opened because it does not exist
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:523)
at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:380)
at org.mybatis.spring.SqlSessionFactoryBean.getObject(SqlSessionFactoryBean.java:547)
at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration.sqlSessionFactory(MybatisAutoConfiguration.java:153)
at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration$$EnhancerBySpringCGLIB$$1.CGLIB$sqlSessionFactory$2(<generated>)
at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration$$EnhancerBySpringCGLIB$$1$$FastClassBySpringCGLIB$$1.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration$$EnhancerBySpringCGLIB$$1.sqlSessionFactory(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 22 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [com/cxs/allmodel/mapper] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:199)
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:519)
... 35 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:57842', transport: 'socket'

Process finished with exit code 1

问题是由于无法找到名为 com/cxs/allmodel/mapper 的类路径资源导致的。这通常意味着 MyBatis 无法找到指定的 Mapper 接口和映射文件。当然,这和虚拟机连接失败没关系

但是最后再看了看,和MyBaits有关,但我目前仅仅是测试web是否成功,后来才知道application.properties中有和MyBaits有关的配置,但我实际上没有使用,给注释掉,终于成功啦!!!

https://www.freesion.com/article/8686658191/

http://t.csdn.cn/yFDJe

发送GET请求到路径”/test”时,该端点会返回字符串”test”作为响应

5.文件夹爆红

1
@SpringBootApplication(scanBasePackages = {"com.easypan"})

easypan爆红,

这个就是命名包名为com.easypan的时候,它真的创建了一个文件夹为com.easypan;而不是自动创建com/easypan;所以需要自己去将文件夹改一下

6.用idea自带的database工具连接mysql时

1
2
Server returns invalid timezone. Need to set 'serverTimezone' property.
Set time zone

因为安装的mysql驱动版本高了,是8.0的,改为5.1的吧

或在url后添加 ?serverTimezone=[GMT]

7.Driver class ‘com.mysql.cj.jdbc.Driver’ not found

com.mysql.jdbc.Driver是MySQL 5.x版本中的驱动程序类。它已经过时,不再被推荐使用,因为它不支持最新的JDBC规范,并且可能存在安全漏洞。

com.mysql.cj.jdbc.Driver是MySQL 8.0版本中的默认驱动程序类。它支持最新的JDBC规范,并提供更好的性能、扩展性和安全性。此外,它还包括了一些新特性,例如支持Unicode字符集和多语言处理等能。

所以我MySQL 5.7确实用不了cj的class

8.plugins什么插件都搜不到

https://plugins.jetbrains.com/

9.启动类启动失败

1
2
Error occurred during initialization of VM
Could not reserve enough space for object heap

我是把run->edit configu.. 设置的vm options参数删除了,或许是因为参数太大,改小一点就可以了

二、vscode

node -v,npm-v未识别

在vscode终端下使用node -v,npm-v未识别(但在cmd上是可以的,证明已配置了全局变量)

解决方案

以管理员身份运行vscode

但实际上,我只是重启了下vscode,就好了

三、nginx

配置详见 http://t.csdn.cn/zEQwv

1.配置后访问为404

nginx.conf配置为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
server {
listen 8000;#访问端口
#listen somename:8080;
server_name easypan.yuleiyun.com;
charset utf-8;

location / { #路由规则
alias D:/phpstudy_pro/WWW/sqli;
#root html; #拼接
# root 和 alias 取其1即可

index index.html index.htm; #index 首页设置
}
location /api {
#alias
proxy_pass http://localhost:7090/api;# 跨域访问
proxy_set_header x-forwarded-for $remote_addr;#客户端ip remote_addr
}
}

访问爆404

解决方案:

反斜杠漏了啊

​ alias D:/phpstudy_pro/WWW/sqli/; 不要丢最后一个反斜杠

四、nodejs的冲突

开发设计的时候要求node版本16.17

当时配置hexo的是v18.

使用旧版本的nodejs导致了hexo进行博客更新出问题,而且yaml格式还乱序了,G!!!!

好好好,这样玩是吧

解决方案

我就用旧的来,再装一遍吧 npm install -g hexo-cli

Please make sure you have the correct access rights and the repository exists.

1
2
3
4
5
6
7
Please make sure you have the correct access rights and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (E:\Myblog\node_modules\hexo-util\lib\spawn.js:51:21)
at ChildProcess.emit (node:events:513:28)
at ChildProcess.cp.emit (E:\Myblog\node_modules\cross-spawn\lib\enoent.js:34:29)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

是git服务器没有发现存储本地的ssh密钥

也就是说,删了一遍已安装的node.js,把公钥忘了呗

解决方案

$ git config user.name ,幸好,这些还记着的

$ ssh -T git@github.com

ssh: connect to host github.com port 22: Connection timed out

重新生成ssh

ssh-keygen -t rsa -C “邮箱”

没用,毁灭吧

http://t.csdn.cn/DV7Ma

可能是网络或其他原因导致22端口被封锁,换端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
67538@LAPTOP-0KTTC8K5 MINGW64 ~/.ssh
$ vim config

67538@LAPTOP-0KTTC8K5 MINGW64 ~/.ssh
$ cat config
Host github.com
Hostname ssh.github.com
Port 443
User git


$ ssh -T git@github.com
The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
//之后就提示success了

好了,可以继续更新了,真难受哇,呜呜呜

https://blog.csdn.net/m0_62159662/article/details/125156695

五、picgo上传失败

1
2
3
4
5
6
7
8
9
 "statusCode": 0,
"message": "connect ETIMEDOUT 20.205.243.168:443",
"stack": "Error: connect ETIMEDOUT 20.205.243.168:443\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1146:16)",
"response": {
"status": 0,
"statusCode": 0,
"body": ""
}
}

解决方案

去picGo配置代理和镜像地址

上传代理为:

1
http://127.0.0.1:7890

六、vue

1.”./lib/locale/lang/zh-cn”

1
Internal server error: No known conditions for "./lib/locale/lang/zh-cn" specifier in "element-plus" package

解决方案

1
import zhCn from "element-plus/es/locale/lang/zh-cn";

1
import zhCn from "element-plus/dist/locale/zh-cn.mjs";

2.test.vue内容没有挂载到index.html上

views下的test.vue

1
2
3
4
5
6
7
8
9
10
11
12
<template>
<div>test</div>
</template>

<!-- <script setup> -->

<script>
</script>

<style lang="scss" scoped>

</style>

App.vue

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<template>

<el-config-provider :locale="locale" :message="config">
<router-view></router-view>

</el-config-provider>

</template>


<script setup>
import { reactive } from "vue";
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
const locale = zhCn;
const config = reactive({
max: 1,
});

</script>

<style lang="scss" scoped>

</style>

router下的index.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { createRouter, createWebHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'Test',
component: () => import("@/views/Test.vue")
}
]
})

export default router

main.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// import './assets/main.css'

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
//import router from './router'
//引入element plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//图标 图标在附件中
//import '@/asserts/icon/iconfont.css'

//import '@/assets/base.scss' //导致不显示test的原因

//引入cookies
import VueCookies from 'vue-cookies'

const app = createApp(App)
app.use(ElementPlus)
app.use(router)

app.mount('#app')

删除main.js中的import '@/assets/base.scss'

知识点

DAO/ENTITY/SERVICE/CONTROLLER

1、DAO层: 持久层 主要与数据库进行交互

DAO层主要是做数据持久层的工作,主要与数据库进行交互。

DAO层首先会创建DAO接口,接着就可以在模块中就可以调用DAO 的接口进行数据业务的而处理,并且不用关注此接口的具体实现类是哪一个类。DAO 层的数据源和数据库连接的参数都是在配置文件中进行配置的。

1
2
3
定义接口
构造Entity的实例queryById
声明增删改查的方法

2、Entity层: 实体层 数据库在项目中的类

1
实体类中,声明变量,一系列地get和set相应的变量

3、Service层:业务层 控制业务

Service层主要负责业务模块的逻辑应用设计。和DAO层一样都是先设计放接口的类,再创建实现的类,然后在配置文件中进行配置其实现的关联。接下来就可以在service层调用接口进行业务逻辑应用的处理。

封装Service层的业务逻辑有利于业务逻辑的独立性和重复利用性。

1
2
3
先定义接口类
构造主键的实例
增删改查方法的声明
1
2
3
定义一个类实现上述接口
定义Dao层的变量
对接口增删改查的重写

4、Controller层: 控制层 控制业务逻辑

Controller层负责具体的业务模块流程的控制,其实就是与前台互交,把前台传进来的参数进行处理,controller层主要调用Service层里面的接口控制具体的业务流程,控制的配置也需要在配置文件中进行。

5、View层: 此层与控制层结合比较紧密,需要二者结合起来协同工发。View层主要负责前台jsp页面的表示

Conroller层和Service层的区别是:Controlle层负责具体的业务模块流程的控制;Service层负责业务模块的逻辑应用设计;

总结:在具体的项目中,其流程为:Controller层调用Service层的方法,Service层调用Dao层中的方法,其中调用的参数是使用Entity层进行传递的。总的来说这样每层做什么的分类只是为了使业务逻辑更加清晰,写代码更加方便,所以有时候也需要根据具体情况来,但是大体的都是这样处理的,因为它其实就是提供一种规则,让你把相同类型的代码放在一起,这样就形成了层次,从而达到分层解耦、复用、便于测试和维护的目的。

————————————————
版权声明:本文为CSDN博主「吴沐珂」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/whz199511/article/details/81532593

子传父参数

1、子组件通过emit传输
2、通过自定义组件传输

对于第一种方法:

首先emit多用于点击事件。

假设父组件中内容如下

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
<template>
<div class="hello">
<h2>我是父组件,我需要建立一些参数</h2>
<h3>我所在地的名称是:{{ msg }}</h3>
<span><mHome @showCityName="updateCityName" /></span>
</div>
</template>

<script>
import mHome from "@/views/Home.vue";
export default {
components: {
mHome,
},
data() {
return {
msg: "北京",
};
},
methods: {
updateCityName(data) {
this.msg = data.msg;
},
},
};
</script>

子组件中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<template>
<div class="home">
<h1>我是子组件</h1>
<h2 @click="change('武汉')">测试其emit组件</h2>
</div>
</template>

<script>
// @ is an alias to /src
export default {
methods: {
change(val) {
let data = {
msg: val,
};
this.$emit("showCityName", data);
},
},
};
</script>


(1)需要在其子组件中定义e m i t 事 件

( 2 )emit的传递子组件和父组件的函数名 showCityName 需要保持一致
————————————————
版权声明:本文为CSDN博主「chengwy_1」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/chengwy_1/article/details/120237776

nginx

关于root和alias还有/

nginx优先匹配/多的

1
2
3
4
5
6
location /pic/{
alias picture/pic/;
}
location /pic/ps/{
root picture;
}

假如访问…/pic/ps/1.jpg,优先匹配第二个,是root,则…/picture/pic/ps/1.jpg,即在前面加上

假如访问…/pic/1.jpg,匹配第一个,是alias,则…/picture/pic/1.jpg,即直接替换

yunpan项目

1.为什么我配置的邮箱是123@ qq.com,但是前端设置任何邮箱都可以发送验证码

且,即使是正确的邮箱,也没有收到信息

Answer:

考虑前端验证和后端验证

此处采用的后端验证,实现两个方法:

1.在服务类接口实现中,判断前端输入的验证码是否正确

2.再去指定邮箱发送随机码

2.注册功能时,后端出现请求参数错误

考虑是前端的表单参数名与后端的对应方法所采用参数名不一致,可能是大小写的不一致。

  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2023-2025 是羽泪云诶
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信