mirror of
https://github.com/chatopera/cosin.git
synced 2025-07-24 08:31:45 +08:00
Destroyed 春松客服:开发环境 (markdown)
parent
bb883570c1
commit
5c783a26f7
293
春松客服:开发环境.md
293
春松客服:开发环境.md
@ -1,293 +0,0 @@
|
||||
# 春松客服
|
||||
|
||||
本文档主要是介绍如何完成春松客服开发环境的搭建。
|
||||
|
||||
## 目录
|
||||
|
||||
[依赖](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E4%BE%9D%E8%B5%96)
|
||||
|
||||
[配置Maven](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E4%BF%AE%E6%94%B9maven2%E9%85%8D%E7%BD%AE)
|
||||
|
||||
[下载代码](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E4%B8%8B%E8%BD%BD%E4%BB%A3%E7%A0%81)
|
||||
|
||||
[数据库](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E6%95%B0%E6%8D%AE%E5%BA%93)
|
||||
|
||||
[安装插件](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E5%AE%89%E8%A3%85%E6%8F%92%E4%BB%B6)
|
||||
|
||||
[生成项目描述](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E7%94%9F%E6%88%90%E9%A1%B9%E7%9B%AE%E6%8F%8F%E8%BF%B0)
|
||||
|
||||
[配置文件](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6)
|
||||
|
||||
[执行/调试](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E6%89%A7%E8%A1%8C%E8%B0%83%E8%AF%95)
|
||||
|
||||
[热更新](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E7%83%AD%E6%9B%B4%E6%96%B0)
|
||||
|
||||
## 依赖
|
||||
|
||||
* [Git](https://git-scm.com/)
|
||||
|
||||
* [Java 8+](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
|
||||
|
||||
* [Maven 3+](https://maven.apache.org/)
|
||||
|
||||
* [IntelliJ IDEA](https://www.jetbrains.com/idea/)或[Eclipse](https://www.eclipse.org/)
|
||||
|
||||
* [Docker 18+](https://www.docker.com/)
|
||||
|
||||
* [Docker compose 1.22+ ](https://docs.docker.com/compose/install/)
|
||||
|
||||
* [MySQL管理客户端 Navicat for MySQL](https://www.navicat.com/en/products/navicat-for-mysql)
|
||||
|
||||
## 修改maven2配置
|
||||
|
||||
确保在pom.xml中存在如下的maven库。
|
||||
|
||||
在```<repositories><repository>```内存在:
|
||||
|
||||
```
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>chatopera</id>
|
||||
<name>Chatopera Inc.</name>
|
||||
<url>https://nexus.chatopera.com/repository/maven-public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
```
|
||||
|
||||
配置文件的示例见 [pom.xml](https://github.com/chatopera/cosin/blob/develop/contact-center/app/pom.xml)。
|
||||
|
||||
如配置后不能下载,请参考[配置文件](https://github.com/chatopera/cosin/issues/137)。
|
||||
|
||||
## 下载代码
|
||||
|
||||
```
|
||||
git clone https://github.com/chatopera/cosin.git
|
||||
```
|
||||
|
||||
## 数据库
|
||||
|
||||
在源码中,有默认使用docker-compose启动服务的描述文件 [docker-compose.yml](https://github.com/chatopera/cosin/blob/develop/docker-compose.yml),用于快速准备开发环境。
|
||||
|
||||
### Elasticsearch
|
||||
春松客服依赖Elasticsearch服务,如果没有Elasticsearch服务,可以用下面的方式创建。
|
||||
|
||||
```
|
||||
cd cosin
|
||||
docker-compose up -d elasticsearch
|
||||
```
|
||||
|
||||
Elasticsearch的配置项在application.properties是
|
||||
|
||||
```
|
||||
spring.data.elasticsearch.cluster-name=elasticsearch
|
||||
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300
|
||||
```
|
||||
|
||||
将cluster-nodes配置为开发服务地址,默认为"YOUR_IP:9300"
|
||||
|
||||
### ActiveMQ
|
||||
春松客服依赖ActiveMQ服务,如果没有ActiveMQ服务,可以用下面的方式创建。
|
||||
|
||||
```
|
||||
cd cosin
|
||||
docker-compose up -d activemq
|
||||
```
|
||||
|
||||
ActiveMQ的配置项在application.properties是
|
||||
|
||||
```
|
||||
spring.activemq.broker-url=tcp://localhost:61616
|
||||
spring.activemq.user=admin
|
||||
spring.activemq.password=admin
|
||||
spring.activemq.pool.enabled=true
|
||||
spring.activemq.pool.max-connections=50
|
||||
```
|
||||
|
||||
将以上值修改为ActiveMQ的实际地址和密码。
|
||||
|
||||
### MySQL
|
||||
春松客服依赖MySQL服务,如果没有MySQL服务,可以用下面的方式创建。
|
||||
|
||||
```
|
||||
cd cosin
|
||||
docker-compose up -d mysql
|
||||
```
|
||||
|
||||
**在第一次执行这个命令时,mysql容器会自动创建```contactcenter```数据库并导入相关的表,因为该容器初始化时加载了```contact-center/config/sql/cskefu-MySQL-slim.sql```文件。**
|
||||
|
||||
连接MySQL服务
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/3538629/44975310-b74b8300-af94-11e8-846b-a36445a61516.png" width="500" />
|
||||
|
||||
使用```docker-compose```启动的服务
|
||||
|
||||
| IP | 用户名 | 密码 | 端口 |
|
||||
| --- | --- | --- | --- |
|
||||
| localhost | root | 123456 | 8037 |
|
||||
|
||||
#### MySQL数据字典
|
||||
|
||||
在线浏览[数据字典](https://chatopera.github.io/cosin/)
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/3538629/60955099-bb71cb00-a332-11e9-8367-16991b893f82.png" width="600"/>
|
||||
|
||||
|
||||
|
||||
### Redis
|
||||
|
||||
春松客服依赖Redis服务,如果没有Redis服务,可以用下面的方式创建。
|
||||
|
||||
```
|
||||
docker-compose up -d redis
|
||||
```
|
||||
|
||||
Redis启动后就可以,不需要其他操作。
|
||||
|
||||
## 安装插件
|
||||
春松客服的一些定制化需求是通过插件的形式发布的,插件让非通用需求和定制化开发的功能的源码与基础代码分离。一些插件是付费的,一些插件是免费的,比如机器人客服插件就是免费开源的。
|
||||
|
||||
插件的安装和源码参考:[https://github.com/chatopera/cosin/tree/osc/public/plugins
|
||||
](https://github.com/chatopera/cosin/tree/osc/public/plugins
|
||||
)
|
||||
## 生成项目描述
|
||||
|
||||
文件目录介绍
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/3538629/44974362-ffb57180-af91-11e8-80d1-a48daa3c3dd5.png" width="200"/>
|
||||
|
||||
|
||||
| 目录 | 说明 |
|
||||
| --- | --- |
|
||||
| ```_m2``` | 用于Dockerfile中,构建镜像 |
|
||||
| ```admin``` | 各种脚本 |
|
||||
| ```app``` | 源代码 |
|
||||
| ```config``` | 数据库文件 |
|
||||
| ```data``` | 数据库数据 |
|
||||
| ```logs``` | 日志 |
|
||||
|
||||
春松客服是基于Java开发到,使用Maven维护项目声明周期。使用Maven命令,生成项目,方便导入到IDE中。
|
||||
|
||||
### Eclipse
|
||||
|
||||
```
|
||||
cd cosin
|
||||
./admin/gen-eclipse.sh
|
||||
```
|
||||
|
||||
### IntelliJ IDEA
|
||||
|
||||
```
|
||||
cd cosin
|
||||
./admin/gen-idea.sh
|
||||
```
|
||||
|
||||
|
||||
## 配置文件
|
||||
|
||||
春松客服是基于spring boot release 1.5.9 开发,配置文件是
|
||||
|
||||
```
|
||||
cosin/contact-center/app/src/main/resources/application.properties
|
||||
```
|
||||
|
||||
|
||||
数据库连接等其他信息,参考该文件,如果需要覆盖这些值,在开发过程中,很常见,可以有以下两个方式:1)使用application-dev.properties;2)使用环境变量。
|
||||
|
||||
### 使用 application-dev.properties 覆盖默认配置
|
||||
|
||||
有两种方式修改默认的配置,一种是用环境变量+properties文件。
|
||||
|
||||
* 设置环境变量
|
||||
|
||||
```
|
||||
SPRING_PROFILES_ACTIVE=dev
|
||||
```
|
||||
* 创建application-dev.properties
|
||||
|
||||
```
|
||||
touch contact-center/app/src/main/resources/application.properties
|
||||
```
|
||||
|
||||
内容如下:
|
||||
|
||||
```
|
||||
# MySQL
|
||||
spring.datasource.url=jdbc:mysql://192.168.2.217:7111/cosinee?useUnicode=true&characterEncoding=UTF-8
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=123456
|
||||
spring.redis.host=192.168.2.217
|
||||
|
||||
|
||||
# Redis服务器连接端口
|
||||
spring.redis.port=7114
|
||||
# Redis服务器连接密码(默认为空)
|
||||
spring.redis.password=123456
|
||||
|
||||
|
||||
# ActiveMQ
|
||||
spring.activemq.broker-url=tcp://192.168.2.217:9007
|
||||
spring.activemq.user=admin
|
||||
spring.activemq.password=123456
|
||||
```
|
||||
|
||||
**此处可以覆盖application.properties中的任何值。**
|
||||
|
||||
### 使用环境变量覆盖默认配置
|
||||
同时,配置信息也可以通过环境变量方式映射,并覆盖application.properties中等配置,其映射方式为```propery```的键转为大写同时```.```和```-```转为```_```。部分环境变量:
|
||||
|
||||
```
|
||||
SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/contactcenter?useUnicode=true&characterEncoding=UTF-8
|
||||
SPRING_DATASOURCE_USERNAME=root
|
||||
SPRING_DATASOURCE_PASSWORD=123456
|
||||
```
|
||||
|
||||
并且,环境变量的值优先级高于properties文件。
|
||||
|
||||
## 导入项目到集成开发工具
|
||||
|
||||
以IDEA为例,导入
|
||||
|
||||
### 配置执行/调试
|
||||
|
||||
配置运行方式为Spring,应用为 ```com.chatopera.cc.app.Application```
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/3538629/45995781-17cd6c00-c0cc-11e8-98d6-0b2caf376999.png" width="800" />
|
||||
|
||||
### 配置环境变量
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/3538629/44974896-96cef900-af93-11e8-8956-82a0a76422db.png" width="400" />
|
||||
|
||||
### 执行/调试
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/3538629/44975019-edd4ce00-af93-11e8-8017-a9868a47feb6.png" width="500" />
|
||||
|
||||
点击"执行"或"调试",服务启动,然后访问 http://localhost:8035 确定服务正常运行了。
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/3538629/44976596-44dca200-af98-11e8-9718-e2677431f047.png" width="800" />
|
||||
|
||||
**用户名**:admin **密码**:admin1234
|
||||
|
||||
### 热更新
|
||||
|
||||
在开发过程中,修改了代码,更新正在以 **“调试”** 模式运行服务,点击"执行旁边的锤子"。
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/3538629/44975743-cf6fd200-af95-11e8-8ca5-3f64cec94caa.png" width="500" />
|
||||
|
||||
更新成功后,提示
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/3538629/44977206-034cf680-af9a-11e8-8eeb-18d5a16b3903.png" width="300" />
|
||||
|
||||
另外, **“调试”** 模式下,也支持断点调试。
|
||||
|
||||
|
||||
[![chatoper banner][co-banner-image]][co-url]
|
||||
|
||||
[co-banner-image]: https://user-images.githubusercontent.com/3538629/42383104-da925942-8168-11e8-8195-868d5fcec170.png
|
||||
[co-url]: https://www.chatopera.com
|
||||
|
Loading…
x
Reference in New Issue
Block a user