My Grails Trail : Use Case 0.4
* Use MySQL as the development database
* Change the default package to com.mhalgosolinc.raygate
Design
Change BuildConfig.groovy and DataSource.groovy for database configuration
Create database in MySQL
Change Config.groovy for the default package name
Implementation
1.
-- Changed BuildConfig.groovy
dependencies { runtime 'mysql:mysql-connector-java:5.1.29' }-- Changed DataSource.groovy
dataSource { pooled = true driverClassName = "com.mysql.jdbc.Driver" dialect = "org.hibernate.dialect.MySQL5InnoDBDialect" } hibernate { cache.use_second_level_cache = true cache.use_query_cache = false cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' } environments { development { dataSource { dbCreate = "create-drop" url = "jdbc:mysql://localhost/raygate" username = "root" password = "" } } test { dataSource { ... } } production { dataSource { ... } } }-- In MySQL, created the database raygate
create database raygate;
2.
-- Config.groovy
grails.project.groupId = 'com.mhalgosolinc.raygate'
Repository
The application has gained some traction with only a few lines of code. It has a landing page that asks for username and password, authenticates, takes to Home page, which has a menubar with some static pages. All the post login pages have access secured based on role and have a Logout link. I ran grails stats and it shows 107 lines of code. Sufficient enough to publish.
The next step involves writing code for user maintenance with functions like User Registration and Forgot Password. These are available built-in with s2ui plugin. Even then this is where I would fumble, because it involves changing the plugin's controller to take care of the additional fields in User entity. Hence it is time to push this app to a repository.
git init, add, commit, remote add, and push was all it took to save the code on github. grails integrate-with --git created a default .gitignore file, to which I added the line **/.DS_Store. And of course I threw in a three-sentence README.md to tell the world what this is about. The repository is https://github.com/mh-github/raygate
References
http://grails.asia/add-mysql-driver-jar-to-a-grails-project-using-buildconfig/
http://mrhaki.blogspot.in/2014/04/grails-goodness-generate-default.html
http://stackoverflow.com/questions/21043132/
Comments
Post a Comment