Maven + Tomcat热部署 [英] Maven + Tomcat hot deploy

查看:97
本文介绍了Maven + Tomcat热部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上搜索了这个问题,但没有发现任何解决方案。我们有一个maven项目,它使用配置文件来构建适合dev / qa / prod环境的工件,使用YUI插件缩小JS和CSS。它使用Spring作为依赖注入,使用struts作为UI框架。 Ibatis用作ORM映射器。我们在Windows上使用Eclipse IDE,并且不使用集成的eclipse,因为我们需要部署Unix服务器。现在,我的问题是,有没有办法以这样的方式部署这个解决方案,即更改js,css,jsp,spring,struts.xml,ibatis映射器文件的applicationContext文件,当然还有Java代码,以便在没有服务器的情况下立即生效重新开始。我记得spring-groovy插件支持重新加载groovy文件中的上下文。所以,我认为应该有一种方式支持热部署。

I've searched on the internet for this question and found no single solution. We have a maven project that uses profiles to build artifact that suits dev/qa/prod environtments, does minification of JS and CSS using YUI plugin. It uses Spring for dependency injection and struts as UI framework. Ibatis is used as ORM mapper. We use Eclipse IDE on windows and are not using integrated eclipse as we need to deploy Unix servers. Now, my question is, is there a way to deploy this solution in such a way that changes to js, css, jsp, applicationContext files of spring, struts.xml, ibatis mapper files and of course Java code to take immediate effect without server restart. I remember spring-groovy plugin supports reload of context for a change in groovy file. So, I presume there should be a way supports hot deploy too.

推荐答案

我发现maven tomcat插件很慢因为它总是使用tomcat的客户端部署程序,并通过管理器上的http调用进行部署,如localhost:8080 / manager / text

I find that maven tomcat plugin is slow because it always use the tomcat's client deployer and deploys by the http calls on the manager like localhost:8080/manager/text

Tomcat有一个由autoDeploy管理的Web应用程序重新加载机制你可以在这里阅读这里。因此,每当应用程序战争发生变化时重新加载,我就对我的 maven-war-plugin 进行了以下更改:

Tomcat has a web application reloading mechanism managed by "autoDeploy" that you can read about it here. So being that it reloads whenever the application war is changed I have made the following change to my maven-war-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <outputDirectory>${my.tomcat.path}</outputDirectory>
    </configuration>
</plugin>

其中

<properties>
    <my.tomcat.path>[MY TOMCAT WEBAPP PATH]</my.tomcat.path>
</properties>

之后我只需要做 mvn编译war:war mvn编译包

这篇关于Maven + Tomcat热部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆