grails-3.0

How to catch “org.springframework.web.multipart.MultipartException” in Grails 3

大兔子大兔子 提交于 2020-06-29 09:14:10
问题 I'm having an awfully hard time catching the error: org.springframework.web.multipart.MultipartException I have the following code: final class UploadTextCommand { MultipartFile contents static constraints = { } } Additionally to handle the post of the file I have this action: def upload = { UploadTextCommand -> ...code... } I've got these settings in the "application.yml" file to force the error: controllers: upload: maxFileSize: 100 maxRequestSize: 100 So I can reliably recreate the

Grails 3 CSRF protection

感情迁移 提交于 2020-01-28 05:25:25
问题 Is it possible to configure CSRF protection in grails3 app using spring-security plugin, I can't find anything except useToken attribute for grails form and then call withForm inside controller. But this is actually not a very flexible solution. I like approach with filter like here 回答1: For csrf protection I reused org.springframework.security.web.csrf.CsrfFilter . You need to define new bean in grails resouces.groovy (See snipet below - csrfFilter bean). You can define your own

What is up to date method to set database in Grails 3?

↘锁芯ラ 提交于 2020-01-25 20:55:30
问题 How to set database in Grails 3? Manual looks obsolete here: http://grails.github.io/grails-doc/3.0.x/guide/single.html#dataSource since it gives an example of setting with grove code like follows: dataSource { pooled = true dbCreate = "update" url = "jdbc:mysql://localhost:3306/my_database" driverClassName = "com.mysql.jdbc.Driver" dialect = org.hibernate.dialect.MySQL5InnoDBDialect username = "username" password = "password" ... while I have application.yml with dataSource: pooled: true

Grails 3.1.0_M2 - Spring-Security-Core 3.0.0.M1 Error

烈酒焚心 提交于 2020-01-05 08:55:08
问题 I have created a test application with command grails create-app helloworld . Then I have added Spring-Security-Core plugin. After that, I have executed the s2-quickstart to create User and Role classes. After that, I launch the application with grails run-app and got these errors: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChainRegistrationBean': Cannot resolve reference to bean 'springSecurityFilterChain' while

Multiple many-to-many associations in one Grails domain class

做~自己de王妃 提交于 2020-01-05 01:10:10
问题 I am using Grails 3.0.6 and am struggling with a complicated and highly interconnected domain model. I have classes with multiple many-to-many associations to other classes and I am left with no choice but to have multiple belongsTo associations on at least one class. I am unable to figure out the syntax to represent this. My domain model was quite complicated, but I was able to reduce my problem to this simplified example: class Graph { static hasMany = [vertices: Vertex] } class OtherClass

Grails 3 mail plugin not working

回眸只為那壹抹淺笑 提交于 2020-01-04 05:05:12
问题 Using Grails 3 it's impossible to get an instance of mailService object, DI is not working: build.gradle compile "org.grails.plugins:mail:1.0.7" testCompile "org.grails.plugins:mail:1.0.7" application.groovy environments { development { //grails.logging.jul.usebridge = true grails.plugin.springsecurity.debug.useFilter = true grails { mail { host = "main.mydomain.com" port = 25 username = "login" password = "password" props = ["mail.smtp.auth":"true"] } } grails.mail.default.from="noreply

How to load datasource configuration from external file in grails 3.1.8?

一世执手 提交于 2020-01-04 04:34:15
问题 I am writing a grails 3.1.8 application. My datasource written in application.groovy file. I want to load datasource configuration like username,password,DB from an external file. Is there any way to do it in grails 3+ versions. Here is my datasource configuration in application.groovy:- hibernate { cache { queries = false use_second_level_cache = true use_query_cache = false region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' } } dataSource { pooled = true jmxExport =

Grails 3: External Logback.groovy file

纵然是瞬间 提交于 2020-01-04 03:54:14
问题 I'm trying to externalize my logback.groovy file by setting the path in my build.gradle file in the bootrun closure: bootRun { if (Environment.currentEnvironment == Environment.PRODUCTION) { jvmArgs = ['-XX:MaxPermSize=2g', '-Xmx2g', '-Dlogging.config=/path/to/config/logback.groovy'] } else { jvmArgs = ['-XX:MaxPermSize=2g', '-Xmx2g'] } } But I am getting: .logback.classic.LoggerContext[default] - Found resource [logback.groovy] at [file:/Users/name/workspace/project/build/resources/main

Grails 3.0.1 - how and where to configure grails.gorm.default.mapping

点点圈 提交于 2020-01-03 13:29:32
问题 I had in the old Config.groovy: grails.gorm.default.mapping = { id generator = 'identity' // send only the dirty fields to the database for updating dynamicUpdate = true dynamicInsert = true } So I put this in the additionally application.groovy, but it won't be respected any more. All updates are full, sending all fields to the database, even the not changed ones. I tried to translate this in application.yml: grails: gorm: default: mapping: id generator: "identity" dynamicUpdate: true

Grails 3 database-migration-plugin initialization error

£可爱£侵袭症+ 提交于 2020-01-02 04:15:11
问题 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