init
This commit is contained in:
107
lms/nladmin-system/doc/mybatis多数据源配置.md
Normal file
107
lms/nladmin-system/doc/mybatis多数据源配置.md
Normal file
@@ -0,0 +1,107 @@
|
||||
# mybatis多数据源配置
|
||||
|
||||
## dynamic-datasource
|
||||
|
||||
### 1、引入依赖
|
||||
|
||||
4.1.3版本是稳定版
|
||||
|
||||
```xml
|
||||
<!-- dynamic-datasource -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>4.1.3</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### 2、配置数据源
|
||||
|
||||
需要注意的是,这里使用了druid,p6spy
|
||||
|
||||
需要配置对应的数据源,使用primary来指明默认的数据源
|
||||
|
||||
```yml
|
||||
#配置数据源
|
||||
spring:
|
||||
autoconfigure:
|
||||
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
|
||||
datasource:
|
||||
dynamic:
|
||||
primary: db1
|
||||
datasource:
|
||||
db1:
|
||||
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
url: jdbc:p6spy:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:stand_lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PWD:12356}
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
db2:
|
||||
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
url: jdbc:p6spy:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:13306}/${DB_NAME:test}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PWD:12356}
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
```
|
||||
|
||||
集成了druid需要去除druid配置
|
||||
|
||||
```yml
|
||||
autoconfigure:
|
||||
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
|
||||
```
|
||||
|
||||
去除框架原来对druid数据源的配置类
|
||||
|
||||
```java
|
||||
//import com.alibaba.druid.pool.DruidDataSource;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.context.annotation.Primary;
|
||||
//
|
||||
//import javax.sql.DataSource;
|
||||
//
|
||||
//@Configuration
|
||||
//@Slf4j
|
||||
//public class DataBaseConfig {
|
||||
//
|
||||
// @Primary
|
||||
// @Bean(name = "dataSource")
|
||||
// @ConfigurationProperties(prefix = "spring.datasource.druid")
|
||||
// public DataSource dataSource() {
|
||||
// return new DruidDataSource();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
```
|
||||
|
||||
排除掉DruidDataSourceAutoConfigure
|
||||
|
||||
在启动类中需要排除掉DruidDataSourceAutoConfigure.class,就是取消Druid的数据源的自动配置类。
|
||||
|
||||
```java
|
||||
@SpringBootApplication(exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
DruidDataSourceAutoConfigure.class
|
||||
})
|
||||
```
|
||||
|
||||
也可以在配置类中
|
||||
|
||||
```yml
|
||||
autoconfigure:
|
||||
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
|
||||
```
|
||||
|
||||
### 3、测试
|
||||
|
||||
使用@DS("db2")注解实现切换数据源
|
||||
|
||||
```java
|
||||
public interface TestMapper extends BaseMapper<JSONObject> {
|
||||
@DS("db2")
|
||||
JSONObject getAll13();
|
||||
}
|
||||
```
|
||||
BIN
lms/nladmin-system/doc/wms.xls
Normal file
BIN
lms/nladmin-system/doc/wms.xls
Normal file
Binary file not shown.
489
lms/nladmin-system/doc/永裕家居LMS系统.postman_collection.json
Normal file
489
lms/nladmin-system/doc/永裕家居LMS系统.postman_collection.json
Normal file
@@ -0,0 +1,489 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "584232a7-9ae4-4ca2-b4e5-d9e66870957e",
|
||||
"name": "永裕家居LMS系统",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "示例",
|
||||
"description": "",
|
||||
"item": [
|
||||
{
|
||||
"name": "LMS登录",
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "56672d9d-9bac-4f23-b77e-809647ef5df4",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "48d9e766-7014-4243-80de-81d63be07da5",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"//postman使用:https://blog.csdn.net/wangyiyan315/article/details/122441791",
|
||||
"",
|
||||
"var JsonData = JSON.parse(responseBody); //定义一个变量,并且将请求返回的内容赋给该变量",
|
||||
"pm.globals.set(\"lms_token\", JsonData.token.slice(7)); //7代表去掉token前面的Bearer加空格",
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\n\t\"username\":\"admin\",\n\t\"password\":\"uefvHbyUCADkudW1MV+/yw9XBWR2Z+KDyq+dqQ+ozr1loClUgqm4XQPsUl87IsXetYBWRDLo7HC++20VHlW80g==\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{lms_url}}/mobile/auth/login",
|
||||
"host": [
|
||||
"{{lms_url}}"
|
||||
],
|
||||
"path": [
|
||||
"mobile",
|
||||
"auth",
|
||||
"login"
|
||||
]
|
||||
},
|
||||
"description": "LMS登录并设置返回的token"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "系统参数分页查询-示例",
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "4f07b550-ab9c-41a4-8dbf-f889ae50b246",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{lms_token}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "/api/param"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{lms_url}}/api/param?sort=id,desc&size=10&page=0",
|
||||
"host": [
|
||||
"{{lms_url}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"param"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "sort",
|
||||
"value": "id,desc"
|
||||
},
|
||||
{
|
||||
"key": "size",
|
||||
"value": "10"
|
||||
},
|
||||
{
|
||||
"key": "page",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"key": null,
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"key": null,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": "求方法参数:{\"whereJson\":{\"sort\":\"id,desc\",\"size\":\"10\",\"page\":\"0\"}}"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "根据编码获取值-示例",
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "4f07b550-ab9c-41a4-8dbf-f889ae50b246",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{lms_token}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "IS_CONNECT_ACS"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{lms_url}}/api/param/getValueByCode",
|
||||
"host": [
|
||||
"{{lms_url}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"param",
|
||||
"getValueByCode"
|
||||
]
|
||||
},
|
||||
"description": "求方法参数:{\"whereJson\":{\"sort\":\"id,desc\",\"size\":\"10\",\"page\":\"0\"}}"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "删除参数-示例",
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "4f07b550-ab9c-41a4-8dbf-f889ae50b246",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{lms_token}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"method": "DELETE",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "[\"0c1d96d335cd4dd6aa0a4bee4b1c45fe\"]"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{lms_url}}/api/param",
|
||||
"host": [
|
||||
"{{lms_url}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"param"
|
||||
]
|
||||
},
|
||||
"description": "求方法参数:{\"whereJson\":{\"sort\":\"id,desc\",\"size\":\"10\",\"page\":\"0\"}}"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "新增参数-示例",
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "4f07b550-ab9c-41a4-8dbf-f889ae50b246",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{lms_token}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"code\":\"test22\",\"is_active\":\"1\",\"remark\":\"test11\",\"name\":\"test11\",\"value\":\"test11\"}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{lms_url}}/api/param",
|
||||
"host": [
|
||||
"{{lms_url}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"param"
|
||||
]
|
||||
},
|
||||
"description": "求方法参数:{\"whereJson\":{\"sort\":\"id,desc\",\"size\":\"10\",\"page\":\"0\"}}"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "修改参数-示例",
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "4f07b550-ab9c-41a4-8dbf-f889ae50b246",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{lms_token}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"method": "PUT",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"code\":\"test22\",\"is_active\":\"8\",\"create_time\":\"2022-10-14 13:33:52\",\"remark\":\"888\",\"update_time\":\"2022-10-14 13:33:52\",\"update_optname\":\"管理员\",\"create_id\":1,\"name\":\"888\",\"id\":\"3f1901b5814d40908bad602854b22aa6\",\"value\":\"8888\",\"update_id\":1,\"create_name\":\"管理员\"}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{lms_url}}/api/param",
|
||||
"host": [
|
||||
"{{lms_url}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"param"
|
||||
]
|
||||
},
|
||||
"description": "求方法参数:{\"whereJson\":{\"sort\":\"id,desc\",\"size\":\"10\",\"page\":\"0\"}}"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ACS请求LMS",
|
||||
"description": "",
|
||||
"item": [
|
||||
{
|
||||
"name": "共挤线申请空盘",
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "4f07b550-ab9c-41a4-8dbf-f889ae50b246",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{lms_token}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"type\":\"1\",\"point_code\":\"GJX01_K\",\"vehicle_code\":\"001\",\"qty\":\"100\",\"vehicle_type\":\"01\",\"vehicle_num\":\"1\"}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{lms_url}}/api/wms/task/apply",
|
||||
"host": [
|
||||
"{{lms_url}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"wms",
|
||||
"task",
|
||||
"apply"
|
||||
]
|
||||
},
|
||||
"description": "求方法参数:{\"whereJson\":{\"sort\":\"id,desc\",\"size\":\"10\",\"page\":\"0\"}}"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "油漆线空盘入库",
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "4f07b550-ab9c-41a4-8dbf-f889ae50b246",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{lms_token}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"code\":\"test22\",\"is_active\":\"1\",\"remark\":\"test11\",\"name\":\"test11\",\"value\":\"test11\"}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{lms_url}}/api/param",
|
||||
"host": [
|
||||
"{{lms_url}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"param"
|
||||
]
|
||||
},
|
||||
"description": "求方法参数:{\"whereJson\":{\"sort\":\"id,desc\",\"size\":\"10\",\"page\":\"0\"}}"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "32f60779-6a66-4d77-80e3-1bc0040e7650",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "fb339152-4984-49bb-8955-3e24baac67ae",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"id": "9b318f5e-373b-4f36-93a5-d131f4f76446",
|
||||
"key": "lms_url",
|
||||
"value": "http://localhost:8010",
|
||||
"type": "string",
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": "5557e8ff-f6ac-45b0-a950-4a8c139d1ae0",
|
||||
"key": "acs_url",
|
||||
"value": "http://localhost:8010",
|
||||
"type": "string",
|
||||
"description": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user