Android从零开始构建项目之目录结构
发布日期:2021-09-28 19:25:43 浏览次数:2 分类:技术文章

本文共 4212 字,大约阅读时间需要 14 分钟。

1.构建项目目录

itcast@itcast:~/prothree/bc$ tree.├── client└── server    └── script

2.创建服务器工程

2.1在server目录下构建工程文件

itcast@itcast:~/prothree/bc/server$ touch server.proitcast@itcast:~/prothree/bc$ tree├── client└── server    ├── script    └── server.pro

2.2用QT打开创建的项目server.pro

注意debug和release的目录,选好后configur构建项目

2.3给工程添加子目录

  1. 在server.pro里面添加TEMPLATE = SUBDIRS
    直接创建有子工程的目录方法File->New File or Project…->Other Project->Subdies Project->Choose…或者双击->name……
  2. 给工程添加子目录DateServer和AppServer
    添加之前要先build一下,不然New Subproject…会是灰色的
    2.1选中工程文件目录server右键->New Subproject…->Other Project->Empty QT Project->Choose…或者双击->name:DateServer->next->finish
    2.2选中工程文件目录server右键->New Subproject…->Other Project->Empty QT Project->Choose…或者双击->name:AppServer->next->finish
  3. 给子工程DateServer.pro和AppServer.pro添加CONFIG += C++11 TUFAO1

3.创建客户端工程

3.1创建司机Driver客户端和乘客User客户端

  1. 创建Driver客户端,打开Android Studio->File->New->New Project->Application name:Driver,Company Domain:itcast,Project Location:home/itcast/prothree/bc/client/Driver->next->next->Empty Activity->finish
  2. 创建User客户端,打开Android Studio->File->New->New Project->Application name:User,Company Domain:itcast,Project Location:home/itcast/prothree/bc/client/User->next->next->Empty Activity->finish

4.创建git仓库

4.0整个项目的目录结构

itcast@itcast:~/prothree/bc$ tree.├── client    ├── Driver        ├── ...    ├── User        ├── ...└── server    ├── AppServer    │   ├── AppServer.pro    │   └── AppServer.pro.autosave    ├── DateServer    │   ├── DateServer.pro    │   └── DateServer.pro.autosave    ├── script    ├── server.pro    └── server.pro.user5 directories, 6 files

4.1创建git仓库

itcast@itcast:~/prothree/bc$ git init初始化空的 Git 版本库于 /home/itcast/prothree/bc/.git/

4.2查看git状态

itcast@itcast:~/prothree/bc$ git status位于分支 master初始提交未跟踪的文件:  (使用 "git add 
..." 以包含要提交的内容) client/ server/提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪)

4.3忽略不需要提交到git的文件

安卓工程创建后有一个

.gitignore文件,会自动忽略不需要提交的文件

itcast@itcast:~/prothree/bc/client/User$ vi .gitignore   1 *.iml  2 .gradle  3 /local.properties  4 /.idea/workspace.xml  5 /.idea/libraries  6 .DS_Store  7 /build  8 /captures

将.gitignore文件拷贝到git目录下,以便于提交的时候忽略不需要提交的文件

itcast@itcast:~/prothree/bc$ cp client/User/.gitignore .

在.gitignore中添加QT工程提交的时候需要忽略的文件

*.iml *.gradle */local.properties */.idea/workspace.xml */.idea/libraries *.DS_Store */build */captures *.pro.user *.o *.d *moc_*.cpp *build-server*

在git仓库中添加文件并标记为待提交状态

itcast@itcast:~/prothree/bc$ git add .gitignore itcast@itcast:~/prothree/bc$ git add client/itcast@itcast:~/prothree/bc$ git add server/itcast@itcast:~/prothree/bc$ git statusitcast@itcast:~/prothree/bc$ git commit -m "init"itcast@itcast:~/prothree/bc$ git status位于分支 master无文件要提交,干净的工作区

(可使用 “git rm –cached [file]…” 撤出暂存区)

创建branch备份

itcast@itcast:~/prothree/bc$ git branch * masteritcast@itcast:~/prothree/bc$ git branch 0.1itcast@itcast:~/prothree/bc$ git branch  0.1* master

如果没有github就在远程linux上建立一个git库

itcast@itcast:~/prothree/bc$ ssh root@121.41.89.69root@121.41.89.69's password: Welcome to Ubuntu 14.04.4 LTS......Welcome to aliyun Elastic Compute Service!root@iZ237l2alupZ:~# root@iZ237l2alupZ:~# mkdir bj06root@iZ237l2alupZ:~# cd bj06/root@iZ237l2alupZ:~/bj06# git init --bare bcInitialized empty Git repository in /root/bj06/bc/

将本地git和远程的git关联,origin只是一个名称可自定义,此处我定义为first,origin被人用了

itcast@itcast:~/prothree/bc$ git remote add first root@121.41.89.69:/root/bj06/bc

将本地文件同步到远程git管理

itcast@itcast:~/prothree/bc$ git push first master:masterroot@121.41.89.69's password: Counting objects: 106, done.Delta compression using up to 4 threads.Compressing objects: 100% (57/57), done.Writing objects: 100% (106/106), 87.17 KiB | 0 bytes/s, done.Total 106 (delta 11), reused 0 (delta 0)To root@121.41.89.69:/root/bj06/bc * [new branch]      master -> master

5.编写自动化部署脚本

5.1MySQL脚本的编写

安装MySQL Workbench,这是MySQL图形管理界面

在本地向远程服务器的mysql导入本地的.sql脚本的脚本

#!/bin/bashusername=`cat db.config | jq '.username' | awk -F\" '{print $2}'`password=`cat db.config | jq '.password' | awk -F\" '{print $2}'`scripts=`find -name "$1"`for script in $scriptsdo    mysql -u$username -p$password < $script    echo $script donedoneecho init database done

完成后记得登录mysql查看一下每个表是否可以打开

show datadases;
use 数据库名;
show tables;
select * from 表名;
千万记得表名,列名之类的不能用mysql的关键字。

转载地址:https://blog.csdn.net/hackywit/article/details/52680132 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:客户端工程的搭建
下一篇:Linux下MySQL和MySQL Workbench的安装

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月12日 17时59分08秒