Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hel-developer-guide
Project
Project
Details
Activity
Releases
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
chenhao
hel-developer-guide
Commits
84a98b5b
Commit
84a98b5b
authored
7 years ago
by
高洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates project-create.md
Auto commit by GitBook Editor
parent
51e86e9e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
159 additions
and
2 deletions
+159
-2
project-create.md
project-create.md
+2
-2
database-config.md
后端开发/database-config.md
+49
-0
database-init.md
后端开发/database-init.md
+108
-0
No files found.
project-create.md
View file @
84a98b5b
...
...
@@ -133,8 +133,8 @@ mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -D archetypeGr
> 目前已经测试过支持的数据库有Mysql,Oracle,SqlServer
> 请修改 `HelParent/core/src/main/java/hel/core/db/liquibase.groovy` 以适配不同的数据库
确定好数据库后,按照
[
Oracle,MySql,Sqlserver数据库配置
](
database-config.md
)
修改项目配置文件。
修改配置文件后,按照
[
创建数据库
](
database-init.md
)
中的步骤创建数据库
确定好数据库后,按照
[
Oracle,MySql,Sqlserver数据库配置
](
/后端开发/database-config.md
)
修改项目配置文件。
修改配置文件后,按照
[
创建数据库
](
/后端开发/database-init.md
)
中的步骤创建数据库
### 编译整个项目
...
...
This diff is collapsed.
Click to expand it.
后端开发/database-config.md
0 → 100644
View file @
84a98b5b
# Oracle,MySql,Sqlserver数据库配置
##配置文件
1.
数据源配置
*
hap 默认使用 JNDI 来配置数据源。数据源的配置独立于项目配置
*
默认使用的 JNDI name 为
`jdbc/hap_dev`
*
tomcat 需要配置 context.xml:
-
Mysql
```xml
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/hap_dev" name="jdbc/hap_dev" type="javax.sql.DataSource" username="hap_dev" password="hap_dev"/>
```
-
Oracle
```xml
<Resource auth="Container" driverClassName="oracle.jdbc.driver.OracleDriver" name="jdbc/hap_dev" type="javax.sql.DataSource" url="jdbc:oracle:thin:@192.168.115.136:1521:HAP" username="hap_dev" password="hap_dev"/>
```
-
SqlServer
```xml
<Resource auth="Container" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://10.211.55.6:1433; DatabaseName=hap_dev" name="jdbc/hap_dev" type="javax.sql.DataSource" username="hap" password="handhapdev"/>
```
*
其他应用服务器 weblogic 等,需要按其配置方法 配置 JNDI
2.
多数据库配置
> hap 项目 根目录 的 pom.xml 中默认包含了 `Oracle`,`Mysql`,`SqlServer` 的 JDBC 驱动,一般不需要改动
*
修改 resources/config.properties
*
当数据库为 oracle 时
```
mybatis.identity=SEQUENCE
```
*
修改 db.type
```
db.type=mysql
# 针对不同的数据库,可选 mysql,oracle,mssql
```
*
修改完毕后复制一份放到 resources/profiles/dev (覆盖)
3.
~~liquibase配置文件~~
*
~~hap-parent/hap/src/java/com/hand/hap/db/liquibase.groovy~~
*
~~新建项目,请修改 {root}/core/src/java/{package}/db/liquibase.groovy~~
*
~~需要修改上面文件中的数据库类型 :
`oracle`
,
`mysql`
,
`sqlserver`
~~
> 步骤 3 :在 2.0版,2016-10月份开始, 已经不需要了, 现在可以根据 db.url 参数自动识别数据库类型
This diff is collapsed.
Click to expand it.
后端开发/database-init.md
0 → 100644
View file @
84a98b5b
# 新建数据库
# 1. 创建数据库-Mysql
> 在开始之前最好修改一下 MySQL的配置文件 my.cnf (or my.ini)
,在
[
mysqld
]
下添加
```
lower_case_table_names=1
character_set_server=utf8
max_connections=500
```
*
用管理员登陆mysql
*
创建数据库hap_dev与hap_prod
```sql
create schema hap_dev default character set utf8;
create schema hap_prod default character set utf8;
```
*
创建用户hap_dev,并将密码设置为hap_dev
```sql
CREATE USER hap_dev@'%' IDENTIFIED BY 'hap_dev';
CREATE USER hap_dev@'localhost' IDENTIFIED BY 'hap_dev';
```
*
将上面新建的hap_dev和hap_prod的权限全部赋予用户hap
```sql
GRANT ALL PRIVILEGES ON hap_dev.* TO hap_dev@'%';
GRANT ALL PRIVILEGES ON hap_dev.* TO hap_dev@'localhost';
GRANT ALL PRIVILEGES ON hap_prod.* TO hap_dev@'%';
GRANT ALL PRIVILEGES ON hap_prod.* TO hap_dev@'localhost';
flush privileges;
```
# 2. 创建数据库-Oracle
*
使用管理员登陆
*
创建表空间
```sql
CREATE BIGFILE TABLESPACE tbs_perm_hap
DATAFILE 'tbs_perm_hap.dat'
SIZE 200M
AUTOEXTEND ON NEXT 20M MAXSIZE 500M;
```
```sql
CREATE TEMPORARY TABLESPACE tbs_temp_hap
TEMPFILE 'tbs_temp_hap.dbf'
SIZE 200M
AUTOEXTEND ON NEXT 20M MAXSIZE 500M;
```
*
创建用户 schema
```sql
CREATE USER hap_dev
IDENTIFIED BY hap_dev
DEFAULT TABLESPACE tbs_perm_hap
TEMPORARY TABLESPACE tbs_temp_hap
QUOTA 200M on tbs_perm_hap;
```
*
授权
```sql
GRANT create session TO hap_dev;
GRANT create table TO hap_dev;
GRANT create view TO hap_dev;
GRANT create any trigger TO hap_dev;
GRANT create any procedure TO hap_dev;
GRANT create sequence TO hap_dev;
GRANT create synonym TO hap_dev;
```
# 3. 创建数据库-sql server
*
使用管理员登陆
*
创建数据库
```sql
CREATE DATABASE hap_dev COLLATE Chinese_PRC_CI_AS;
```
```sql
CREATE DATABASE hap_prod COLLATE Chinese_PRC_CI_AS
```
*
创建用户 hap 并授权
```sql
sp_addlogin 'hap','handhapdev';
use hap_dev
go
sp_adduser 'hap','hap'
go
sp_addrolemember 'db_owner','hap'
go
```
```sql
use hap_prod
go
sp_adduser 'hap','hap'
go
sp_addrolemember 'db_owner','hap'
go
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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