1. 程式人生 > 實用技巧 >基礎-02快速開發(人人開源)

基礎-02快速開發(人人開源)

一、建立maven工程

二、人人開源

2.1 人人開源前後臺專案搭建

克隆到本地

git clone https://gitee.com/renrenio/renren-fast-vue.git
git clone https://gitee.com/renrenio/renren-fast.git

1、renren-fast(後臺服務)

將拷貝下來的“renren-fast”刪除“.git”後,拷貝到“gulimall”工程根目錄下,然後將它作為gulimall的一個module

建立“gulimall_admin”的資料庫,然後執行“renren-fast/db/mysql.sql”中的SQl指令碼

修改“application-dev.yml”檔案,預設為dev環境,修改連線mysql的url和使用者名稱密碼

spring:
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        druid:
            driver-class-name: com.mysql.cj.jdbc.Driver
            url: jdbc:mysql://192.168.137.14:3306/gulimall_admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
            username: root
            password: root

啟動“gulimall_admin”,然後訪問“http://localhost:8080/renren-fast/”

2、renren-fast-vue(前端專案)

安裝node.js,並且安裝倉庫

npm config set registry http://registry.npm.taobao.org/
PS D:\tmp\renren-fast-vue> npm config set registry http://registry.npm.taobao.org/
PS D:\tmp\renren-fast-vue> npm install
npm WARN [email protected] requires a peer of ajv@>=4.10.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

up to date in 17.227s
PS D:\tmp\renren-fast-vue> 

PS D:\tmp\renren-fast-vue> npm run dev

> [email protected] dev D:\tmp\renren-fast-vue
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

 10% building modules 5/10 modules 5 active ...-0!D:\tmp\renren-fast-vue\src\main.js(node:19864) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:19864) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:19864) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:19864) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:19864) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:19864) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:19864) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:19864) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:19864) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:19864) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency

2.2 人人開原始碼生成器

1、clone專案

https://gitee.com/renrenio/renren-generator.git

然後將該專案放置到“gulimall”的跟路徑下,然後新增該Module,並且提交到github上

2、修改配置

renren-generator/src/main/resources/generator.properties

#程式碼生成器,配置資訊
mainPath=com.bigdata
#包名
package=com.bigdata.gulimall
moduleName=product
#作者
author=cosmoswong
#Email
[email protected]
#表字首(類名不會包含表字首)
tablePrefix=pms_

3、執行專案

訪問:http://localhost:80/

點選“renren-fast”,能夠看到它將“renren-fast”的所有表都列舉了出來:

選擇所有的表,然後點選“生成程式碼”,將下載的“renren.zip”,解壓後取出main資料夾,放置到“gulimall-product”專案的main目錄中。

下面的幾個module,也採用同樣的方式來操作。

三、其他

1、npm下載失敗解決方法

常見問題1:“Module build failed: Error: Cannot find module 'node-sass”

執行過程中,出現“Module build failed: Error: Cannot find module 'node-sass’報錯問題”

使用淘寶映象

用npm install -g cnpm --registry=https://registry.npm.taobao.org ,從淘寶映象那下載,然後cnpm下載成功。

最後輸入cnpm install node-sass --save。npm run dev終於能跑起來了!!!

常見問題2:cnpm - 解決 " cnpm : 無法載入檔案 C:\Users\93457\AppData\Roaming\npm\cnpm.ps1,因為在此係統上禁止執行指令碼。有關詳細資訊 。。。 "

https://www.cnblogs.com/500m/p/11634969.html

所有問題的根源都在“node_modules”,npm install之前,應該將這個資料夾刪除,然後再進行安裝和執行。

再次執行npm run dev恢復正常