springblade+saber脚手架搭建

举报
瀛洲骇客 发表于 2024/08/15 10:23:01 2024/08/15
【摘要】 本文介绍使用springblade+saber脚手架搭建进行web开发的相关内容。

1.前言

最近要自己做一个小项目,自己在家里用,需要搭建一个开发的脚手架,由于本人是Java开发出身,天生倾向于Java项目,在网上找了半天,找到了bladex这个框架。 官网地址:bladex.vip/#/
看了下资料还挺全,还有演示地址。因为要做的小项目有富文本编辑功能,看了下页面,基本符合需求,于是决定使用这个框架搭建自己的脚手架。


2.springblade+saber介绍

bladex是一个已经很成熟的企业级框架,是商用的,这边我这边需求比较低,使用开源版就可以。他的后端主要是微服务版,也有boot版本。

后端springblade地址:gitee.com/smallc/Spri…

因为我不需要微服务,所以需要切换到boot分支;

前端提供了2个版本 vue+element ui版本和 react+ant design版。由于本身是主要做后端,选择了简单一点的vue版本。

前端saber地址:gitee.com/smallc/Sabe…

SpringBlade系列三份免费基础文档 :pan.baidu.com/s/1XAkGInrf… 提取码: bxkg

下面让我们根据文档开始搭建。

3.springblade搭建

springblade的官方文档主要是讲微服务的,boot版本内容较少,只能靠自己摸索。

本次使用的springblade是最近的3.4.1版本;

3.1 搭建前准备:

mysql环境 (5.7.32版本,官方要求5.7+)

redis环境(5.0.8版本,官方要求4.0+ 一开始不知道,后来搭建了无法登录又添加的)

Java环境(1.8.0.131)

IDEA

navcat

mavne

3.2 Springblade代码初始化

先把源代码导入IDEA,

使用maven进行构建,使用阿里云镜像站作为maven远程仓

mvn clean install

整个构建过程比较和谐,没有出现什么问题。

这个项目有四个application文件,application.yml中是放基础配置;其他三个分别是开发环境、测试环境、生产环境配置。

我这边当然是使用的生产环境,在application-dev.yml中修改redis和msyql配置

#数据源配置 spring: redis: ##redis 单机环境配置 host: 127.0.0.1 port: 6379 password: database: 0 ssl: false ##redis 集群环境配置 #cluster: # nodes: 127.0.0.1:7001,127.0.0.1:7002,127.0.0.1:7003 # commandTimeout: 5000 datasource: url: jdbc:mysql://127.0.0.1:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 username: root password: 123456 driver-class-name: com.mysql.cj.jdbc.Driver

3.3 数据库初始化

创建blade数据库


导入项目中的sql文件,由于前端使用vue,所以导入blade-saber-mysql.sql

导入后表如下图

image.png

3.4 启动项目

从启动类Application.java启动项目。


看到项目启动,访问swagger地址:http://127.0.0.1/doc.html,如下图所示,后端项目启动成功


4.saber搭建

使用saber版本为3.4.0版本;

4.1 前端环境准备

nodejs (16.13.1版本,官方建议10.15版本以上)

npm(8.1.2版本,官方建议5.6版本以上)

VScode

4.2 saber代码初始化

把代码导入VScode.前端的官方文档比较详细,按官方文档做即可。

npm install -g yarn --registry=registry.npm.taobao.org

yarn config set registry registry.npm.taobao.org -g

cd Saber

yarn install

意外发生了

卡在这里,报错如下

npm install node-sass npm ERR! code 1 npm ERR! path D:\code\Saber-master\node_modules\node-sass npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js npm ERR! Building: C:\Program Files\nodejs\node.exe D:\code\Saber-master\node_modules\node-sass\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library= npm ERR! gyp info it worked if it ends with ok npm ERR! gyp verb cli [ npm ERR! gyp verb cli 'C:\Program Files\nodejs\node.exe', npm ERR! gyp verb cli 'D:\code\Saber-master\node_modules\node-sass\node_modules\node-gyp\bin\node-gyp.js', npm ERR! gyp verb cli 'rebuild', npm ERR! gyp verb cli '--verbose', npm ERR! gyp verb cli '--libsass_ext=', npm ERR! gyp verb cli '--libsass_cflags=', npm ERR! gyp verb cli '--libsass_ldflags=', npm ERR! gyp verb cli '--libsass_library=' npm ERR! gyp verb cli ] npm ERR! gyp info using node-gyp@7.1.2 npm ERR! gyp info using node@16.13.1 | win32 | x64 npm ERR! gyp verb command rebuild [] npm ERR! gyp verb command clean [] npm ERR! gyp verb clean removing "build" directory npm ERR! gyp verb command configure [] npm ERR! gyp verb find Python Python is not set from command line or npm configuration npm ERR! gyp verb find Python Python is not set from environment variable PYTHON npm ERR! gyp verb find Python checking if "python3" can be used npm ERR! gyp verb find Python - executing "python3" to get executable path npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error npm ERR! gyp verb find Python checking if "python" can be used npm ERR! gyp verb find Python - executing "python" to get executable path npm ERR! gyp verb find Python - executable path is "C:\Program Files\Python27\python.exe" npm ERR! gyp verb find Python - executing "C:\Program Files\Python27\python.exe" to get version npm ERR! gyp verb find Python - version is "2.7.18" npm ERR! gyp info find Python using Python version 2.7.18 found at "C:\Program Files\Python27\python.exe" npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 16.13.1 npm ERR! gyp verb command install [ '16.13.1' ] npm ERR! gyp verb install input version string "16.13.1" npm ERR! gyp verb install installing version: 16.13.1 npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed npm ERR! gyp verb install version is already installed, need to check "installVersion" npm ERR! gyp verb got "installVersion" 9 npm ERR! gyp verb needs "installVersion" 9 npm ERR! gyp verb install version is good npm ERR! gyp verb get node dir target node version installed: 16.13.1 npm ERR! gyp verb build dir attempting to create "build" dir: D:\code\Saber-master\node_modules\node-sass\build npm ERR! gyp verb build dir "build" dir needed to be created? D:\code\Saber-master\node_modules\node-sass\build npm ERR! gyp verb find VS msvs_version not set from command line or npm config npm ERR! gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt npm ERR! gyp verb find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details npm ERR! gyp verb find VS looking for Visual Studio 2015 npm ERR! gyp verb find VS - not found npm ERR! gyp verb find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details npm ERR! gyp ERR! find VS looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! find VS For more information consult the documentation at: npm ERR! gyp ERR! find VS github.com/nodejs/node… npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use npm ERR! gyp ERR! stack at VisualStudioFinder.fail (D:\code\Saber-master\node_modules\node-sass\node_modules\node-gyp\lib\find-visualstudio.js:121:47) npm ERR! gyp ERR! stack at D:\code\Saber-master\node_modules\node-sass\node_modules\node-gyp\lib\find-visualstudio.js:74:16 npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\code\Saber-master\node_modules\node-sass\node_modules\node-gyp\lib\find-visualstudio.js:351:14) npm ERR! gyp ERR! stack at D:\code\Saber-master\node_modules\node-sass\node_modules\node-gyp\lib\find-visualstudio.js:70:14 372:16 npm ERR! gyp ERR! stack at D:\code\Saber-master\node_modules\node-sass\node_modules\node-gyp\lib\util.js:54:7 npm ERR! gyp ERR! stack at D:\code\Saber-master\node_modules\node-sass\node_modules\node-gyp\lib\util.js:33:16 npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:390:28) npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1064:16) npm ERR! gyp ERR! System Windows_NT 10.0.19044 npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "D:\code\Saber-master\node_modules\node-sass\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" npm ERR! gyp ERR! cwd D:\code\Saber-master\node_modules\node-sass npm ERR! gyp ERR! node -v v16.13.1 npm ERR! gyp ERR! node-gyp -v v7.1.2 npm ERR! gyp ERR! not ok npm ERR! Build failed with error code: 1 npm ERR! A complete log of this run can be found in: npm ERR! D:\npm\node_cache_logs\2022-09-07T08_53_13_494Z-debug.log

参考 (88条消息) 安装node-sass失败的解决方案_Heigl swift的博客-CSDN博客_node_modules\node-sass

npm install -g mirror-config-china --registry=registry.npm.taobao.org

npm install node-sass

然后再 yarn install

 如果后台地址有变化,在这个文件修改

启动前端项目

访问http://localhost:1888/

5. 小结

登录以后发现开源版没有富文本编辑器。。。好吧还需要自己集成一个,这个下篇文章再说。




【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。