grails-3.0

Grails3 controller integration test case fail: No thread-bound request found

不问归期 提交于 2019-12-07 04:49:43
问题 With just simple following controller action spock integration-test. Here is my Test. @Integration @Rollback class TestControllerSpec extends Specification { def setup() { } def cleanup() { } void "test something"() { setup: def c = new TestController() c.index() expect: c.response.contentType !=null } } getting following Exception java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request

How to use external .groovy config file in Grails 3

时间秒杀一切 提交于 2019-12-07 03:27:15
问题 Section 24.3 in Externalized Configuration indicates a .properties or .yml file can be used for external config, but I would like my external config to be a .groovy file just like my application.groovy file which I have already converted from .yml . How can I make this happen? Grails version 3.2.0.M2 UPDATE: I was able to get this working based on the answer provided by @Michal_Szulc Note that the ConfigSlurper needed the current environment to work correctly. Also note that these changes are

Grails 3 and Java 8 time support

ε祈祈猫儿з 提交于 2019-12-06 13:49:28
In grails 3 application, I see that new java.time classes are persisted to database. Dynamic queries and create criteria works. However, I am wondering if there is some better way how to store these time data to database. When I look to database I see some binary data, it seems it just serialize the time objects. Is there any similar plugin as joda-time-plugin or is there any way how to configure database mapping for java.time classes? Edit : Grails 3.1.1 has hibernate 5 so this is not an issue anymore... Grails I finally found a solution. First of all hibernate 5 implements persistent for

Grails 3.0.9: Spock integration tests' @Rollback annotation is not working

喜你入骨 提交于 2019-12-06 06:17:43
I'm currently working on some integration (or functional, I'm not really a QA but back-end dev, so I might be sloppy with terms) REST tests for our project, we are using Grails 3.0.9, Spock Framework 1.0-Groovy-2.4 and PostgreSQL DB for testing. Also we have separate DB for testing purposes, it is still crucial that changes are rolled back after each test. I have looked through Grails testing doc and was trying to use @Rollback annotation as described in examples - and it is just not working, changes are still committed to DB. As it is work project, I can't provide some real code snippets,

Grails 3 database-migration-plugin initialization error

雨燕双飞 提交于 2019-12-05 11:01:06
I recently added database-migration-plugin to my grails 3.0.11 app. The problem is when I try to run-app I get a following error: ERROR grails.boot.GrailsApp - Application startup failed Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springLiquibase_dataSource': Invocation of init method failed; nested exception is liquibase.exception.ChangeLogParseException: java.lang.IllegalArgumentException: Script text to compile cannot be null! Looks like it can't find changelog.xml in my grails-app/migrations folder. My build.gradle file

convert configuration file application.yml to application.groovy in Grails 3.x

☆樱花仙子☆ 提交于 2019-12-05 10:10:26
I am trying to create a simple Grails 3 project and got stuck with something really simple. So I want my data source properties to come from VM options that I set in my IntelliJ IDE. Before in Grails 2.x, I just used to do something like: environments { development{ //Database connection properties def dbserver = System.properties.getProperty('dbserver') def dbport = System.properties.getProperty('dbport') ............ dataSource { url: "jdbc:sqlserver://${dbserver}:${dbport};databaseName=${dbname} } } Now that I have application.yml, how do I access "System.properties" and embed it in yml? I

Grails 3.0 adding an inline plugin

让人想犯罪 __ 提交于 2019-12-05 09:00:13
问题 I created simple grails 3.0 applications using commands below: create-app admin --profile=web create-plugin core --profile=plugin Now, I wanted to use core as an inline plugin in admin build, which is a web application. We can easily do that in grails version < 3.0 in buildconfig. Where can I do that in grails 3.0. Every help is worth appreciated. 回答1: Inplace plugins have been replaced by multi project Gradle builds. See the Grails 3 functional test suite for an example https://github.com

Configuring Spring Boot Security to use BCrypt password encoding in Grails 3.0

删除回忆录丶 提交于 2019-12-05 08:18:47
In Grails 3.0, how do you specify that Spring Boot Security should use BCrypt for password encoding? The following lines should provide a sense of what I think needs to be done (but I'm mostly just guessing): import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder PasswordEncoder passwordEncoder passwordEncoder(BCryptPasswordEncoder) My application loads spring-boot-starter-security as a dependency: build.gradle dependencies { ... compile "org.springframework.boot:spring-boot-starter-security" And I have a

How to use external .groovy config file in Grails 3

限于喜欢 提交于 2019-12-05 08:15:59
Section 24.3 in Externalized Configuration indicates a .properties or .yml file can be used for external config, but I would like my external config to be a .groovy file just like my application.groovy file which I have already converted from .yml . How can I make this happen? Grails version 3.2.0.M2 UPDATE: I was able to get this working based on the answer provided by @Michal_Szulc Note that the ConfigSlurper needed the current environment to work correctly. Also note that these changes are to be made to the my_grails_app/grails-app/init/my_grails_app/Application.groovy file, not the my

UrlMappings to point a URL to an asset pipeline file in Grails

白昼怎懂夜的黑 提交于 2019-12-04 05:01:52
In Grails 3.0 how do you map a URL to a file under the assets folder? For example: http://localhost:8080/favicon.ico --> grails-app/assets/images/bookmark.ico I've tried a few test mappings, such as: grails-app/controllers/UrlMappings.groovy class UrlMappings { static mappings = { ... "/t1.png" (uri: "/assets/images/test.png") "/t2.png" (uri: "/assets/test.png") "/t3.png" (uri: "/images/test.png") "/t4.png" (dir: "assets/images", file: "test.png") ... } } ...but they all result in a 500 server error. If you are not using the Asset-Pipeline you can map static resources to URLs by following the