简体   繁体   中英

How do I disable grails from loading certain plugins loaded by default when starting up?

I wasn't aware that grails will load a set of default plugins when starting up. This isn't obvious when running in dev mode using run-app. But when I built a war and dropped it into a app server, the memory usage goes crazy high and I see the following snippet of logs:

31767 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [i18n] with version [2.1.0] loaded successfully 31770 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [logging] with version [2.1.0] loaded successfully 31771 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [core] with version [2.1.0] loaded successfully 32039 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [groovyPages] with version [2.1.0] loaded successfully 32053 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [urlMappings] with version [2.1.0] loaded successfully 32060 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [controllers] with version [2.1.0] loaded successfully 32076 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [domainClass] with version [2.1.0] loaded successfully 32079 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [dataSource] with version [2.1.0] loaded successfully 32547 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [cacheHeaders] with version [1.1.5] loaded successfully 32548 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [redis] with version [1.3.2] loaded successfully 32549 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [resources] with version [1.1.6] loaded successfully 32549 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [services] with version [2.1.0] loaded successfully 32551 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [servlets] with version [2.1.0] loaded successfully 32561 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [mimeTypes] with version [2.1.0] loaded successfully 32571 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [codecs] with version [2.1.0] loaded successfully 32579 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [filters] with version [2.1.0] loaded successfully 32579 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [validation] with version [2.1.0] loaded successfully 32583 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [scaffolding] with version [2.1.0] loaded successfully 32598 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [converters] with version [2.1.0] loaded successfully 32664 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [lesscssResources] with version [1.3.0] loaded successfully 32676 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [cachedResources] with version [1.0] loaded successfully 32684 [main] INFO org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager - Grails plug-in [zippedResources] with version [1.0] loaded successfully

How do I disable the loading of certain plugins because I don't need them? Say, the scaffold plugin and the domainClass plugin (this is a HTML 5 app with no DB connection)

Thanks !

So, after following up with you over another medium of communication, I've confirmed that you'd like to remove:

  1. domainClass
  2. dataSource
  3. validation
  4. scaffolding

Let's start with dataSource. According to this thread and this follow-up JIRA , it is possible to simply delete DataSource.groovy (or remove the contents of dataSource {}) to prevent the plugin from firing, but the Grails project lead, Graeme Rocher , chimes in that even if you have no persistence layer outside of web services, you still need an in memory data source for the application to function correctly. Or at least to pass tests.

As far as I can tell, the only way to remove unneeded plugins is to use a grails.war.resources callback (ie, there's no way to handle it with Grail's built in dependency management functionality). Follow this link for an example of how to use a callback to delete arbitrary jars.

Those plugins should in in your application.properties or your BuildConfig.groovy depending on how you set up the plugins. Some of those plugins may be dependancies of the ones you installed.

Looks like you have the resources plugin along with a number of plugins to help with resources in general. (Zipped, cached, lesscss, cacheHeaders ...) You probably want all of those plugins.

You also have redis are you seeing plugins you aren't using in production? If you are you can always load them conditionally in BuildConfig in side the plugins closure we do the following:

if (Environment.current in [Environment.DEVELOPMENT, Environment.TEST]) {
  compile ":build-test-data:2.0.2"
}

You probably need those plugins you are seeing as they may be built into grails. The base of grails a decent sized memory footprint. You can conditionally add the plugins you need but you can't toss everything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM