beego搭建

获取beego    go get github.com/astaxie/beego

升级beego    go get -u github.com/astaxie/beego

安装bee工具        go get github.com/beego/bee

查看bee版本   bee version

进入src创建新项目

bee new hospital

自动编译部署

bee run

自动生成代码(控制器,模型,视图)

bee generate scaffold user -fields="id:int64,name:string,gender:int,age:int" -driver=mysql -conn="root:123@tcp(127.0.0.1:3306)/imooc"

其中:

user 是指数据表名

-fields=后面的id:int64,name:string,gender:int,age:int根据自己创建的user表字段来

-driver=数据库类型 选项有 mysql /oracle/sql 等

conn="root:123@tcp(127.0.0.1:3306)/imooc"

conn="数据库用户名:密码@tcp(数据库IP:端口号)/当前项目数据库名字"

此时我的1.数据库用户名是root,2.密码123,3.数据库IP:127.0.0.1,4.端口号3306, 5.当前项目数据库名字imooc

猜你喜欢

转载自blog.csdn.net/qq_40876291/article/details/84111708