在Tomcat中使用普通的jars创建纤细的grails war文件?

问题描述 投票:0回答:1

生成的grails war文件包含所有默认的jars,大约有30 mb。我需要减小这个文件的大小,以便频繁地在远程Tomcat容器中进行测试部署。所以我试图使用通用的libs tomcat技术。但由于某些原因,这个过程并不成功。

以下是我正在采取的步骤

1) 首先,我把所有的jar文件从web-inflib目录下复制到服务器的公共目录下,如下图所示。

enter image description here

这里是varlibtomcat7confcatalina.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) 当我访问webapps时,我得到 "Page cant be found 404 error"。

我感谢任何关于我做错了什么的帮助。谢谢

更新。

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

enter image description here

tomcat grails grails-2.2
1个回答
-1
投票

你最好的办法是限制依赖关系,这只能通过你的build.gradle文件来完成。把你需要的东西删掉。

如果你知道一个插件是由另一个依赖提供的,就用 "provided"。

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

另外,剪掉double includes(比如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中明确声明你需要的部分,排除你不需要的部分。你必须更聪明地构建就是了。

© www.soinside.com 2019 - 2024. All rights reserved.