闲话
为嘛我要写一篇这个呢?因为我促头写项目的最大的一个原因就是,项目的前期架子搭建不起来,所以我就很害怕做项目,但是今天,我!决定来记录一下搭建架子的过程,以后看着这篇博客无脑跟着搭就行了,我只需要专注于项目的实现。另外下一篇我打算总结一下自己做项目的方法论,省的做起来东一榔头西一锤子的。
后端のSpringboot
这里我的springboot是和mybatis进行配合操作数据库,所以必要的只有整合mybatis
- 引入依赖
创建项目的时候勾选spring web、mysql、jdbc、mybatis frame - 连接上数据库
我必须操作上数据库啊,所以我得进去application.yml
spring:
datasource:
url: jdbc:mysql://localhost:3306/bank?useUnicode=true&characterEncoding=utf8
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
-
一切完活,准备三层以及pojo实体类
准备controller、service、mapper、pojo三个包然后分别编写类并写上注解 -
实现mapper这个包里的接口
创建目录结构:static/mybatis/(mapper + mybatis-config.xml)
其中mapper中放直接实现上面的mapper接口的xml,mybatis-config.xml是能将xml和接口联系起来的东西
mapper.xml统一模板:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!--基本的东西都不用配置,因为springboot配好了-->
</configuration>
然后将他们一起放进yml中,加载进整个项目:
mybatis:
config-location: classpath:static/mybatis/mybatis-config.xml
mapper-locations: classpath:static/mybatis/mapper/*.xml
- 反正最基本的架子已经搭好了,接下来需要什么你再自己加(比如日志依赖、Lombok依赖,热更新等依赖)
前端のVue
1.在想要创建项目的文件夹下,打开win + R,打开cmd,输入:
vue create myapp
2.安装axios到生产环境
npm i axios --save
然后就可以在需要的.vue文件中import
以上是必要的,剩下的按需(比如elementui等)