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

☆樱花仙子☆ 提交于 2019-12-05 10:10:26

Turned out I had an issue, I needed to put 'default' keyword within quotes. Like :

grails {
    profile = 'web'
    codegen {
        defaultPackage = 'defPack'
    }
}

info {
    app {
        name = '@info.app.name@'
        version = '@info.app.version@'
        grailsVersion = '@info.app.grailsVersion@'
    }
}

spring {
    groovy {
        template['check-template-location'] = false
    }
}

hibernate {
    naming_strategy = 'org.hibernate.cfg.DefaultNamingStrategy'
    cache {
        queries = false
    }
}

grails {
    mime {
        disable {
            accept {
                header {
                    userAgents = ['Gecko', 'WebKit', 'Presto', 'Trident']
                }
            }
        }

        types {
            all = '*/*'
            atom = 'application/atom+xml'
            css = 'text/css'
            csv = 'text/csv'
            form = 'application/x-www-form-urlencoded'
            html = ['text/html', 'application/xhtml+xml']
            js = 'text/javascript'
            json = ['application/json', 'text/json']
            multipartForm = 'multipart/form-data'
            rss = 'application/rss+xml'
            text = 'text/plain'
            hal = ['application/hal+json', 'application/hal+xml']
            xml = ['text/xml', 'application/xml']
        }
    }
    urlmapping {
        cache {
            maxsize = 1000
        }
    }
    controllers {
        defaultScope = 'singleton'
    }
    converters {
        encoding = 'UTF-8'
    }
    views {
        'default' { codec = 'html' }//THIS WAS THE SOURCE OF ERROR
        gsp {
            encoding = 'UTF-8'
            htmlcodec = 'xml'
            codecs {
                expression = 'html'
                scriptlets = 'html'
                taglib = 'none'
                staticparts = 'none'
            }
        }
    }
}

def dbserver = System.properties.getProperty('dbserver')
def dbport = System.properties.getProperty('dbport')
def dbusername = System.properties.getProperty('dbusername')
def dbpassword = System.properties.getProperty('dbpassword')
def dbname = System.properties.getProperty('dbname')

dataSource {
    pooled = true
    jmxExport = true
    driverClassName = 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
    dbCreate = ''
    username = dbusername
    password = dbpassword
}
environments {
    development {
        dataSource {
            url = 'jdbc:sqlserver://${dbserver}:${dbport};databaseName=${dbname}'
        }
    }
}

May be not a direct answer to your question. You can access system properties in application.yml by adding below to build.gradle

tasks.withType(org.springframework.boot.gradle.run.BootRunTask) {
systemProperties = System.properties

Reference: https://github.com/grails/grails-core/issues/9086

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!