Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-demo-base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gic_demo
gic-demo-base
Commits
35fae6c4
Commit
35fae6c4
authored
Jun 03, 2019
by
朱瑞泽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add doc
parent
f17889aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
0 deletions
+115
-0
README.md
README.md
+115
-0
snapshot_01.png
gic-demo-helper/src/main/resources/snapshot_01.png
+0
-0
No files found.
README.md
0 → 100644
View file @
35fae6c4
# demo 工程说明
### 工程结构
!
[
](gic-demo-helper/src/main/resources/snapshot_01.png)
### 生成 mybatis model mapper xml
gic-demo-helper工程,配置generatorConfig_test.xml。
```
xml
<context
id=
"testTables"
targetRuntime=
"MyBatis3"
>
<!-- 配置数据库连接 -->
<jdbcConnection
driverClass=
"com.mysql.jdbc.Driver"
connectionURL=
"jdbc:mysql://xxxx:6634/test?characterEncoding=utf-8"
userId=
"userId"
password=
"password"
>
</jdbcConnection>
<!-- 配置Model生成 -->
<javaModelGenerator
targetPackage=
"com.gic.demo.project.service.entity"
targetProject=
"src/main/java"
>
<property
name=
"enableSubPackages"
value=
"true"
/>
</javaModelGenerator>
<!-- 配置 mapper xml 生成 -->
<sqlMapGenerator
targetPackage=
"mapper"
targetProject=
"src/main/resources"
>
<property
name=
"enableSubPackages"
value=
"true"
/>
</sqlMapGenerator>
<!-- 配置 mapper 对应接口 -->
<javaClientGenerator
type=
"XMLMAPPER"
targetPackage=
"com.gic.demo.project.service.dao.mapper"
targetProject=
"src/main/java"
>
<property
name=
"enableSubPackages"
value=
"true"
/>
</javaClientGenerator>
<!-- 指定数据库表 -->
<table
tableName=
"tab_gic_demo_enterprise"
enableSelectByExample=
"false"
enableDeleteByExample=
"false"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
selectByExampleQueryId=
"false"
/>
<table
tableName=
"tab_gic_demo_store"
enableSelectByExample=
"false"
enableDeleteByExample=
"false"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
selectByExampleQueryId=
"false"
/>
</context>
```
生成代码
```
java
public
class
GeneratorStartUp
{
public
static
void
main
(
String
[]
args
)
{
try
{
List
<
String
>
warnings
=
new
ArrayList
<>();
ClassLoader
classloader
=
Thread
.
currentThread
().
getContextClassLoader
();
InputStream
is
=
classloader
.
getResourceAsStream
(
"generatorConfig_test.xml"
);
ConfigurationParser
cp
=
new
ConfigurationParser
(
warnings
);
Configuration
config
=
cp
.
parseConfiguration
(
is
);
DefaultShellCallback
callback
=
new
DefaultShellCallback
(
true
);
MyBatisGenerator
myBatisGenerator
=
new
MyBatisGenerator
(
config
,
callback
,
warnings
);
myBatisGenerator
.
generate
(
null
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
```
### 生成雪花id
未来 UniqueIdUtils 会集成到 gic-commons 4.x 里
```
java
public
class
TestRun
{
public
static
void
main
(
String
[]
args
)
{
// 生成long型id
UniqueIdUtils
.
uniqueLong
();
// 生成hex字符串型id
UniqueIdUtils
.
uniqueLongHex
();
}
}
```
### sharding-jdbc 配置
1.
参照 sharding-jdbc 配置说明配置分表,保存到mongodb
2.
修改 Apollo配置 COMMON.sharding sharding.shardingId
3.
配置xml
```
xml
<bean
id=
"dataSource"
class=
"com.gic.sharding.sdk.ShardingDatasource"
init-method=
"init"
>
<property
name=
"shardingId"
value=
"${sharding.shardingId}"
/>
<property
name=
"maxSize"
value=
"${jdbc.maxsize}"
/>
<property
name=
"urlType"
value=
"${sharding.urlType:inner}"
/>
</bean>
```
### dubbo 服务
参考 gic 3.x,com.alibaba.dubbo.container.Main 替换为 com.gic.commons.DubboMain 。
### web rest 服务
使用 spring boot 内嵌 tomcat 启动
```
java
/**
* Spring Boot Web 启动类
*
* @author zhurz
*/
@SpringBootApplication
@ImportResource
(
value
=
{
// spring 配置初始化xml
"classpath*:gic-demo-init.xml"
,
// 通用 dubbo 配置
"classpath*:dubbo-setting.xml"
,
// dubbo api 配置
"classpath*:dubbo-gic-demo-web.xml"
,
// 拦截器配置
"classpath*:spring-interceptor.xml"
})
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
ConfigurableApplicationContext
context
=
SpringApplication
.
run
(
Main
.
class
,
args
);
DubboContextUtil
.
setApplicationContext
(
context
.
getParent
());
}
}
```
gic-demo-helper/src/main/resources/snapshot_01.png
0 → 100644
View file @
35fae6c4
34.6 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment