不使用docker部署项目需要启动的一些服务-cnblog

  • mysql
  • redis
    • ./redis-serve
  • nginx:
    • ./nginx
  • 源springboot项目:
    • nohup java -jar helloworld-1.0-SNAPSHOT.jar &> hello.log &

springboot项目部署到服务器的注意点

  • application.yml

    • redis配置
    • 记得改为localhost
    server:
      port: 18081
    
    spring:
      application:
        name: com.lingxin.LingxinApplication
      datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.cj.jdbc.Driver
        url: jdbc:mysql:///studentsystem?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
        username: root
        password: root
      redis:
        port: 6379
        host: localhost
        database: 0
      cache:
        redis:
          time-to-live: 180000
      main:
        allow-bean-definition-overriding: true
    
    mybatis-plus:
      global-config:
        db-config:
          id-type: assign_id
    
        banner: off
      configuration:
        #将下划线去掉,使用驼峰命名法
        map-underscore-to-camel-case: true
        log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    
    lingxin:
      oss:
        accessKey: LTAI5tQvuDd3Etto8Cm7Fcuc
        secret: PW9PYcA9mQnJAbKY7EwI3X6MaL1kY5
        endpoint: oss-cn-shanghai.aliyuncs.com
        bucketName: lingxin-tanhua
        url: https://lingxin-tanhua.oss-cn-shanghai.aliyuncs.com
    

前端vue项目

// 导入axios
import axios from 'axios'

// 导入element的加载组件
import { Loading } from 'element-ui'

// 封装一个具有请求根地址的request
const request = axios.create({
  // json假数据
  baseURL: 'http://www.lingxin1123.work:18081/'
})

// request.defaults.withCredentials = true

// 定义一个加载实例
let loadingInstance = null

// 请求拦截器
request.interceptors.request.use((config) => {
  // 配置token字段
  const token = sessionStorage.getItem('token')
  if (token) {
    config.headers.Authorization = token
  }

  console.log(config)
  // 加载效果
  loadingInstance = Loading.service({ fullscreen: true })
  // 在发起请求时加载element-ui的加载效果
  return config
})

// 响应拦截器
request.interceptors.response.use(
  (response) => {
    // 关闭loading加载效果
    loadingInstance.close()
    return response
  },
  (error) => {
    // 另外的错误
    loadingInstance.close()
    return error.response
  }
)

// 导出request

export default request

posted @ 2023-02-04 16:27  凌歆  阅读(115)  评论(0)    收藏  举报