grails-2.0


How to execute mysql scripts in cloudfoundry

假如想象 提交于 2020-02-07 15:46:53
问题 I have a .sql file (initial sql scripts). I have recently deployed application in cloudfoundry, So I want to run these scripts to make application work, Scripts will update more than 5 db tables. Is there any other way to run the mysql scripts from the grails application on start up Or Is there any provision to run the scripts in the cloudfoundry. 回答1: you have several options here. The first one (which I recommend), is to use something like http://liquibase.org/ (there is a Grails plugin for

Adding changes listeners in Grails' GORM

淺唱寂寞╮ 提交于 2020-02-02 13:38:29
问题 I'm new to Grails and I'm using Grails 2.0.1. I want to add a persistence event listener for changes in objects for a domain class, so I tried the code in Bootstrap.groovy as given in the user guide: def init = { applicationContext.addApplicationListener(new FooBarListener()) } And I get the following error message: ERROR context.GrailsContextLoader - Error executing bootstraps: No such property: applicationContext for class: BootStrap How can I get the applicacionContext property from inside

What is the difference between withTransaction and withNewTransaction?

亡梦爱人 提交于 2020-01-24 04:02:06
问题 What is the difference between the following actions? def someAction() { User.withTransaction { ... } } and def someAction() { User.withNewTransaction { ... } } When do I use what? When a grails action contains only a Transaction block. In this case I guess withTransaction and withNewTransaction are the same, because each action has its own transaction. Is this true? 回答1: I believe these functions have to do with transaction isolation semantics. The withTransaction function will participate

Grails 2 can't login with spring security when using multiple databases

China☆狼群 提交于 2020-01-23 10:43:26
问题 On Grails 2.0.3, I installed Spring Security Core and created the User, UserRole and Role objects as per the tutorial: http://blog.springsource.org/2010/08/11/simplified-spring-security-with-grails/ All went fine until I decided to add a second datasource in preparation for accessing objects from a different database. DataSource.groovy looks like this: test { dataSource_product { dbCreate = "update" url = "jdbc:mysql://localhost/products" pooled = true driverClassName = "com.mysql.jdbc.Driver

Grails 2.0 integration test pollution?

假如想象 提交于 2020-01-21 07:36:26
问题 So i have a small integration test that houses 5 tests in total. Running that test exclusively results in all tests passed. However running my entire test suite results in 4 test failures of the 5. I've just recently upgraded to grails-2.0 from 1.3.7 and i switched from hsqldb to h2. Has anyone any pointers in which direction i should be looking in order to fix this (test-pollution) problem? Domain model Integration test: class SeriesIntegrationTests extends GrailsUnitTestCase { Series series

How to integrate angular js into grails 2.3.4?

时光毁灭记忆、已成空白 提交于 2020-01-21 01:47:28
问题 I am running on grails 2.3.4 and though about integrating angularjs in my next application. I think the best way from the server side is to use grails REST integration in the domain and controller classes. However here I am stuck. How to get grails to communicate with angularjs?(over the index.gsp ?, If so how to integrate it?) What would be a good architecture? I really appreciate your answers!!! PS.: I know that there is a grails angular js plugin. However I do see any reason for using that

Grails + Mongodb + Spock: NullPointerException being thrown when doing embedded field query

耗尽温柔 提交于 2020-01-15 11:34:33
问题 On one service I'm trying to do something like: Organization.withCriteria { eq( "active", true ) eq( "location.region", region) } which is working but when calling the method inside a unit test I get: java.lang.NullPointerException at org.grails.datastore.mapping.keyvalue.mapping.config.KeyValuePersistentEntity.getPropertyByName(KeyValuePersistentEntity.java:75) at grails.gorm.CriteriaBuilder.validatePropertyName(CriteriaBuilder.java:954) at grails.gorm.CriteriaBuilder.eq(CriteriaBuilder.java

Grails + Mongodb + Spock: NullPointerException being thrown when doing embedded field query

谁都会走 提交于 2020-01-15 11:34:05
问题 On one service I'm trying to do something like: Organization.withCriteria { eq( "active", true ) eq( "location.region", region) } which is working but when calling the method inside a unit test I get: java.lang.NullPointerException at org.grails.datastore.mapping.keyvalue.mapping.config.KeyValuePersistentEntity.getPropertyByName(KeyValuePersistentEntity.java:75) at grails.gorm.CriteriaBuilder.validatePropertyName(CriteriaBuilder.java:954) at grails.gorm.CriteriaBuilder.eq(CriteriaBuilder.java

Grails unit test verify mock method called

不羁岁月 提交于 2020-01-15 05:45:51
问题 In my unit test, I mock a service (which is a ref of the class under test). Like: given: def mockXxService = mockFor(XxService) mockXxService.demand.xxx(1) {->} service.xxService = mockXxService when: service.yyy() then: // verify mockXxService's xxx method is invoked. For my unit test, I want to verify that mockXxService.xxx() is called. But grails document's mockControl.verify() doesn't work for me. Not sure how to use it correctly. It is very similar to mockito's verify method. Anyone

Grails: Defining a JSON custom marshaller as static method in domain

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 19:21:27
问题 I'm using Grails 2.4.2. As can be seen here: https://grails.org/Converters+Reference You can create a static method in your domain with your custom marshaller to render the JSON in the controller. Like that: Domain: // a class to output in JSON package com.sample class User { String login String passwd // JSON definition of the User object static { grails.converters.JSON.registerObjectMarshaller(User) { return [ login: it.login ] } } Then in your controller: def user = new User(login:'bob',

工具导航Map