在tomcat中使用普通罐子创建slim grails war文件?

时间:2020-05-14 06:32:13

标签: tomcat grails grails-2.2

生成的带有所有默认jar的grails war文件约为30 mb。我需要减小此大小,以便将测试频繁部署到远程tomcat容器。所以我正在尝试使用常见的lib tomcat技术。该过程由于某种原因无法正常工作。

这是我正在采取的步骤

1)首先,如下所示,将所有jar文件从web-inf / lib目录复制到服务器的公共目录中

enter image description here

这是/var/lib/tomcat7/conf/catalina.properties common.loader配置。

enter image description here

2)然后我按如下方式配置grails配置

enter image description here

3)然后,我使用> grails war --nojars

生成的war文件为6.42 mb。

4)然后我将war文件复制到tomcat webapps目录。

5)当我访问Web应用程序时,出现“找不到页面404错误”。

感谢您对我做错事的任何帮助。谢谢!

更新:

这是在catalina.out中记录的错误。该应用程序是nojars。

enter image description here

1 个答案:

答案 0 :(得分:-1)

您最好的选择是限制依赖关系;这只能通过build.gradle文件AFAIK来完成。剪裁成只有您需要的东西。

如果您知道某个插件是由另一个依赖项提供的,请使用“提供”

provided 'org.grails.plugins:cache:4.0.0'
compile "org.grails.plugins:async"
provided "org.grails:grails-logging"
provided "org.grails:grails-plugin-i18n"

另外,切出双重内容(例如groovy-all)和其他不需要的内容:

provided 'org.codehaus.gpars:gpars:1.2.1', {
    exclude group:'org.multiverse', module:'multiverse-core'
    exclude group:'org.codehaus.groovy', module: 'groovy-all'
}

在gradle.build中具体声明您需要的部分,并排除不需要的部分。您必须对构建更加精明。

相关问题