部署项目经历
本文最后更新于241 天前,其中的信息可能已经过时,如有错误请发送邮件到3368129372@qq.com

移动端项目地址:chinosama.cn

前端使用vercel部署

  1. 经常出现它擅自为我添加请求的url地址,我写"/api"或者"chinosama.cn/api" 它就自动在这个前面加上个"www.chinosama.cn/api",后来我把请求url改成api.chinosama.cn/api就解决了
  2. 跨域选择在后端配置,但是前端出现了"(blocked: mixed-content)"的问题。因此在阿里云整了个SSL证书,把后端地址整成https的了(早知道博客也用阿里的了,cloudflare的卡死)

后端用宝塔面板部署

后端踩得坑就更多了

  1. 打包后无法运行jar包,显示
    ERROR org.springframework.boot.SpringApplication - Application run failed
    org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property 'spring.profiles.active' imported from location 'class path resource [application-prod.yaml]' is i
    nvalid in a profile specific resource [origin: class path resource [application-prod.yaml] from mobile-backend-0.0.1-SNAPSHOT.jar - 16:13]
        at org.springframework.boot.context.config.InvalidConfigDataPropertyException.lambda$throwOrWarn$1(InvalidConfigDataPropertyException.java:125)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092)
        at org.springframework.boot.context.config.InvalidConfigDataPropertyException.throwOrWarn(InvalidConfigDataPropertyException.java:122)
        at org.springframework.boot.context.config.ConfigDataEnvironment.checkForInvalidProperties(ConfigDataEnvironment.java:362)

    查找后把

    spring:
        profiles:
            active: prod

    改为了

    spring:
        config:
            activate:
                on-profile: prod

    虽然不知道为啥但是能用了

  2. 数据库
    经常提示密码错误,可以先查一查运行环境是否是prod,地址可以写localhost,我因为一直是dev运行的还以为线上数据库写的有啥问题
    此外存储数据时显示“Unknown collation: 'utf8mb4_0900_ai_ci”。这是mysql8才有的字符集和校对集,mysql5应该改为'utf8mb4_general_ci'
  3. 运行指令
    /usr/local/btjdk/jdk8/bin/java -jar -Xmx1024M -Xms256M  /www/wwwroot/mobile-backend/mobile-backend-0.0.1-SNAPSHOT.jar --server.port=8101 --spring.profiles.active=prod

    可复写运行端口,确定运行环境

  4. 配置nginx
    listen 80;
    listen 443 ssl http2;
    server_name api.chinosama.cn;
    index index.html index.htm default.htm default.html;
    root /www/wwwroot/mobile-backend;

    主要还是这个地址要改成线上地址,端口不用动

感谢您的收看~
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇