NoteBook开发日记二
1.vue-cli脚手架创建项目的配置2.SpringBoot后端配置MyBatis配置文件上传、数据、druid、热部署、redis配置
1.vue-cli脚手架创建项目的配置
首先要配置的就是解决跨域问题,在项目根目录下新建vue.config.js,配置如下:
module
.exports
= {
devServer
:{
port
: 8080,
host
: 'localhost',
https
: false,
open
: true,
proxy
: {
'/dev-api': {
target
: 'http://localhost:8081',
changeOrigin
: true,
pathRewrite
: {
'^/dev-api': '',
}
}
}
},
lintOnSave
: false,
}
devServer:开发环境下的Server配置
port:vue项目启动访问端口host:vue项目启动访问ip地址https:是否启用httpsopen:项目编译完成后是否自动打开网页访问 proxy:代理配置,用于解决跨域问题
‘dev-api’:每个请求之前要加的路径
target:要代理的目标地址changeOrigin:改变源hostpathRewrite:路径重写 lintOnSave:下载了eslint代码格式检查模块,配置保存时不检查格式,不然格式不对就会编译报错
上述配置中最主要的就是proxy,通俗地讲每个请求地址之前都要加上dev-api,例如请求路径dev-api/upload,经过代理后就变成了http://localhost:8081/upload,解决了跨域的问题。
2.SpringBoot后端配置
MyBatis配置
mybatis:
mapper-locations: classpath
:mapper/*
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
type-aliases-package: com.zjr.admin.entities
文件上传、数据、druid、热部署、redis配置
server:
port: 8081
spring:
servlet:
multipart:
max-file-size: 50MB
max-request-size: 50MB
datasource:
url: jdbc
:mysql
://localhost
:3306/admin
?serverTimezone=GMT+8
&useUnicode=true
&characterEncoding=UTF
-8
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
druid:
initial-size: 5
min-idle: 5
max-active: 20
max-wait: 60000
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
stat-view-servlet:
url-pattern: /druid/*
allow: 127.0.0.1
reset-enable: false
login-username: root
login-password: ZJR199925
devtools:
restart:
enabled: true
additional-paths: src/main/java
exclude: mapper/**
freemarker:
cache: false
redis:
database: 0
host: localhost
port: 6379
password:
jedis:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
timeout: 1000
这章就到这啦,后面有时间还会继续更新的。