grails 开发笔记
来源:互联网 发布:微信公众号助手 源码 编辑:程序博客网 时间:2024/06/06 12:58
http://www.grails.org/
1.官网下载安装grails,配置path环境变量到bin目录下
在命令行输入grails查看变化,如果运行成功就代表安装成功了
安装idea开发工具
2.build.gradle配置文件设置
compile 'org.grails.plugins:spring-security-core:3.1.1'runtime 'mysql:mysql-connector-java:5.1.39'
一个用来配置闭包用户登录权限设置
一个用来配置mysql jdbc驱动
3.mysql配置
dataSource: pooled: true jmxExport: true driverClassName: com.mysql.jdbc.Driver username: yangchuan password: 2719283s+environments: development: dataSource: dbCreate: update url: jdbc:mysql://localhost:3306/tianxing?useUnicode=true&characterEncoding=UTF-8&useSSL=false test: dataSource: dbCreate: create-drop url: jdbc:mysql://101.251.244.37:3306/tianxing?useUnicode=true&characterEncoding=UTF-8&useSSL=false production: dataSource: dbCreate: update url: jdbc:mysql://10.0.8.100:3306/tianxing?useUnicode=true&characterEncoding=UTF-8&useSSL=false properties: jmxEnabled: true initialSize: 5 maxActive: 50 minIdle: 5 maxIdle: 25 maxWait: 10000 maxAge: 600000 timeBetweenEvictionRunsMillis: 5000 minEvictableIdleTimeMillis: 60000 validationQuery: SELECT 1 validationQueryTimeout: 3 validationInterval: 15000 testOnBorrow: true testWhileIdle: true testOnReturn: false jdbcInterceptors: ConnectionState defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
要注意格式对称以及首行缩进问题,如果配置标准不一致就会运行失败.
4.用户登陆设置
使用命令grails s2-quickstart com.test User Role 创建用户账户domian
使用命令grails generate-all com.test.User 来创建需要的view和controller
在init目录下的BootStrap中配置用户名与密码:
package dfhfaximport com.dfhfax.Roleimport com.dfhfax.Userimport com.dfhfax.UserRoleclass BootStrap { def init = { servletContext -> if(Role.count()<1){ println 'init role data' def r = new Role() r.authority='ROLE_ADMINISTRATOR' r.save() } if (User.count() < 1) { println 'init user data' def c = new User() c.username = 'yangchuan' c.password = '2719283s+' c.save() } if (UserRole.count() < 1) { println 'init user role data' UserRole.create(User.findByUsername('yangchuan'), Role.findByAuthority('ROLE_ADMINISTRATOR')) } } def destroy = { }}
在需要访问页面对应的controller上添加访问权限的标识
@Secured(['ROLE_ADMINISTRATOR'])
0 0
- grails 开发笔记
- GSP 学习笔记(1)-- GRAILS开发
- grails学习笔记-2、开发环境搭建
- grails 笔记
- grails 笔记
- Grails 笔记
- grails学习笔记-4、通过例子了解grails开发的基本流程
- grails学习笔记-1、grails概述
- Grails学习笔记1
- Grails学习笔记2
- Grails学习笔记3
- Grails学习笔记4
- grails学习笔记
- grails学习笔记
- Grails环境部署开发
- Grails开发Web服务
- Grails开发命令
- grails开发总结报告
- web前端在线工具,持续更新中
- FPGA设计-时序约束(中篇-实例分析)
- HBuilder mui 手势事件 转自【B5教程网】:http://www.bcty365.com/content-146-2389-1.html
- tableView刷新指定的cell 或section和滚动到指定的位置
- 数论
- grails 开发笔记
- 如何添加自定义的msg到ORB SLAM
- 算法复杂度符号
- Struts1 HTML标签
- Win10 Edge_Chrome浏览器快捷键
- 51单片机
- 无法连接aws里的MySql
- PAT乙级1038
- oracle基本介绍