本文介绍了HotSwaping代码转换为“mvnDebug tomcat:run”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我使用启动tomcat mvnDebug tomcat:运行

代码更改后我需要使用 mvn tomcat:redeploy

After Code-change i need to use mvn tomcat:redeploy.

这是次优的,因为我经常只改变现有方法体的内容。

This is sub-optimal because i often only change content of existing method-bodys.

我可以HotSwap方法的主体进入运行时,并将热重新部署作为后备?

Can I HotSwap the method's body into the runtime, and hot-redeploy as a fallback?

我不幸发现没有像 maven-hotswap-plugin

... <application>
  <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
  <locale-config>
   <default-locale>de_DE</default-locale>
  </locale-config>
  <resource-bundle>
   <base-name>Message</base-name>
   <var>message</var>
  </resource-bundle>
  <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
 </application>
</faces-config>



web.xml:



web.xml:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
    <listener-class>
        org.springframework.web.context.request.RequestContextListener
    </listener-class>
</listener>



pom.xml:



pom.xml:

<dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-envers</artifactId>
        <version>4.3.0.Final</version>
    </dependency>
    <dependency>
        <groupId>net.java.dev.ajax4jsf</groupId>
        <artifactId>ajax4jsf</artifactId>
        <version>1.0.6</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.6.6.Final</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-api</artifactId>
        <version>1.2.10</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-impl</artifactId>
        <version>1.2.10</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.myfaces.tomahawk</groupId>
        <artifactId>tomahawk12</artifactId>
        <version>1.1.9</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.sun.facelets</groupId>
        <artifactId>jsf-facelets</artifactId>
        <version>1.1.14</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>3.1.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.6</version>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.2-1004-jdbc41</version>
    </dependency>

    <dependency>
        <groupId>servletapi</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <contextReloadable>true</contextReloadable>
            </configuration>
        </plugin>
    </plugins>
</build>


推荐答案

你可以使用 - 它完全按照您的预期工作。您只需要指定javaagent,它将在运行时重新加载所有类和框架更改。它也适用于远程服务器

You can use Jrebel - it works exactly as you expect. You just need to specify javaagent and it will reload all classes and framework changes during runtime. It also works with remote servers

要将其与maven项目集成,您必须添加,它将生成所有配置(rebel.xml)文件。

To integrate it with maven project you have to add jrebel-maven-plugin, which will generate all configuration (rebel.xml) files.

如果没有JRebel,你可以使用标准的HotSwap机制,但它只允许重新加载方法体

Without JRebel you can use standard HotSwap mechanism but it only allows to reload method bodies

这篇关于HotSwaping代码转换为“mvnDebug tomcat:run”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 07:03