maven resin 热部署

原文链接:http://breezylee.iteye.com/blog/1997630

一般用maven构建的项目,在eclipse中编码完之后,都要先停止服务器,重新maven编译一次,然后再重启服务器,比较麻烦。

假设服务器用resin,在resin的项目配置文件xx.conf里,定位项目路径如下配置:

      <web-app id="/" document-directory="E:\java\eclipse-jee-luna-SR2-win32-x86_64\workspace\resin\target\resin">
          <session-config>
             <session-max>1000</session-max>
             <session-timeout>30</session-timeout>
             <enable-cookies>true</enable-cookies>
             <enable-url-rewriting>true</enable-url-rewriting>
           </session-config>

      </web-app>

 这个路径指向maven构建完成之后的target项目路径,此时就像刚刚说的那样,编码一次,要重新构建,比较麻烦。但是,如果路径不指向构建好的target项目,而指向maven的自身组织的src下面main下面的webapp的话,再相应地配置好编译路径和lib路径(也要配置在target文件夹下面),就不用停止服务器再构建项目,而是直接在运行中的服务器上面,看到编码之后的效果,如:

      <web-app id="/" document-directory="E:\java\eclipse-jee-luna-SR2-win32-x86_64\workspace\resin\target\resin">
          <session-config>
             <session-max>1000</session-max>
             <session-timeout>30</session-timeout>
             <enable-cookies>true</enable-cookies>
             <enable-url-rewriting>true</enable-url-rewriting>
           </session-config>
		   
		   <!-- configurate web directory -->  
            <prologue>  
                <class-loader>  
                     <!-- configurate class directory -->  
                    <compiling-loader path="E:\java\eclipse-jee-luna-SR2-win32-x86_64\workspace\resin\target\classes"/>
                    <!-- configurate library directory -->  
                    <library-loader path="E:\java\eclipse-jee-luna-SR2-win32-x86_64\workspace\resin\target\WEB-INF\lib"/> 
                </class-loader>  
            </prologue>  
      </web-app>


compiling-loader:是自动编译代码存放的位置, 需要先确定自己工程的编译目录

以上配置是因为eclipse的自动编译功能,修改文件之后,不用重新maven编译构建,就已经编译好项目了,就像普通项目运行在tomcat的debug模式下,比较方便文件修改。但如果项目重新加了 jar包,这个方法就不录了,还得老老实实地停止服务器,重新maven构建,再启动服务器了。


=============================================

以下是我自己项目中的resin.xml文件,没有使用上面的配置, 也能直接热部署。 不知道是哪里配置了。 

<!--
   - Resin 3.0 configuration file.
  -->
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">
  <!--
     - Logging configuration for the JDK logging API.
    -->
  <log name="" level="info" path="stdout:" timestamp="[%H:%M:%S.%s] "/>
  <log name="com.caucho.java" level="config" path="stdout:"
       timestamp="[%H:%M:%S.%s] "/>
  <log name="com.caucho.loader" level="config" path="stdout:"
       timestamp="[%H:%M:%S.%s] "/>

  <!--
     - For production sites, change dependency-check-interval to something
     - like 600s, so it only checks for updates every 10 minutes.
    -->
  <dependency-check-interval>2s</dependency-check-interval>

  <!--
     - You can change the compiler to "javac" or jikes.
     - The default is "internal" only because it's the most
     - likely to be available.
    -->
  <javac compiler="internal" args=""/>

  <!-- Security providers.
     - <security-provider>
     -    com.sun.net.ssl.internal.ssl.Provider
     - </security-provider>
    -->

  <!--
     - If starting bin/resin as root on Unix, specify the user name
     - and group name for the web server user.
     -
     - <user-name>resin</user-name>
     - <group-name>resin</group-name>
    -->

  <!--
     - Configures threads shared among all HTTP and SRUN ports.
    -->
 

  <!--
     - Configures the minimum free memory allowed before Resin
     - will force a restart.
    -->
  <min-free-memory>1M</min-free-memory>

  <server>
    <!-- adds all .jar files under the resin/lib directory -->
    <class-loader>
      <tree-loader path="${resin.home}/lib"/>
      <tree-loader path="${server.root}/lib"/>
    </class-loader>

    <!-- Configures the keepalive -->
    <keepalive-max>500</keepalive-max>
    <keepalive-timeout>120s</keepalive-timeout>

    <!-- The http port -->
    <http server-id="" host="*" port="2222"/>

    <!--
       - SSL port configuration:
       -
       - <http port="8443">
       -   <openssl>
       -     <certificate-file>keys/gryffindor.crt</certificate-file>
       -     <certificate-key-file>keys/gryffindor.key</certificate-key-file>
       -     <password>test123</password>
       -   </openssl>
       - </http>
      -->

    <!--
       - The local cluster, used for load balancing and distributed
       - backup.
      -->
    <cluster>
      <srun server-id="" host="127.0.0.1" port="6720"/>
    </cluster>

    <!--
       - Configures the persistent store for single-server or clustered
       - in Resin professional.
      -->
    <resin:if test="${resin.isProfessional()}">
      <persistent-store type="cluster">
        <init path="session"/>
      </persistent-store>
    </resin:if>

    <!--
       - Enables/disables exceptions when the browser closes a connection.
      -->
    <ignore-client-disconnect>true</ignore-client-disconnect>

    <!--
       - For security, use a different cookie for SSL sessions.
       - <ssl-session-cookie>SSL_JSESSIONID</ssl-session-cookie>
      -->

    <!--
       - Enables the cache (available in Resin Professional)
      -->
    <resin:if test="${isResinProfessional}">
      <cache path="cache" memory-size="8M"/>
    </resin:if>

    <!--
       - Enables periodic checking of the server status.
       -
       - With JDK 1.5, this will ask the JDK to check for deadlocks.
       - All servers can add <url>s to be checked.
      -->
    <resin:if test="${isResinProfessional}">
      <ping>
        <!-- <url>http://localhost:8080/test-ping.jsp</url> -->
      </ping>
    </resin:if>

    <!--
       - Defaults applied to each web-app.
      -->
    <web-app-default>
      <!--
         - Extension library for common jar files.  The ext is safe
         - even for non-classloader aware jars.  The loaded classes
         - will be loaded separately for each web-app, i.e. the class
         - itself will be distinct.
        -->
      <class-loader>
        <tree-loader path="${server.root}/ext-webapp"/>
      </class-loader>

      <!--
         - Sets timeout values for cacheable pages, e.g. static pages.
        -->
      <cache-mapping url-pattern="/" expires="5s"/>
      <cache-mapping url-pattern="*.gif" expires="60s"/>
      <cache-mapping url-pattern="*.jpg" expires="60s"/>

      <!--
         - Servlet to use for directory display.
        -->
      <servlet servlet-name="directory"  servlet-class="com.caucho.servlets.DirectoryServlet"/>

      <!--
         - Enable PHP (required JDK 5)
        -->
      <resin:if test="${java.isJava5()}">
        <servlet servlet-name="resin-php"
                 servlet-class="com.caucho.quercus.servlet.QuercusServlet">
          <init>
          </init>
        </servlet>

        <servlet-mapping url-pattern="*.php" servlet-name="resin-php"/>
     </resin:if>

      <!--
         - Enable EL expressions in Servlet and Filter init-param
        -->
      <allow-servlet-el/>

      <!--
         - For security, set the HttpOnly flag in cookies.
         - <cookie-http-only/>
        -->
    </web-app-default>

    <!--
       - Sample database pool configuration
       -
       - The JDBC name is java:comp/env/jdbc/test
       -
         <database>
           <jndi-name>jdbc/mysql</jndi-name>
           <driver type="org.gjt.mm.mysql.Driver">
             <url>jdbc:mysql://localhost:3306/test</url>
             <user></user>
             <password></password>
            </driver>
            <prepared-statement-cache-size>8</prepared-statement-cache-size>
            <max-connections>20</max-connections>
            <max-idle-time>30s</max-idle-time>
          </database>
      -->

    <!--
       - Default host configuration applied to all virtual hosts.
      -->
    <host-default>
      <class-loader>
        <compiling-loader path="webapps/WEB-INF/classes"/>
        <library-loader path="webapps/WEB-INF/lib"/>
      </class-loader>

      <!--
         - With another web server, like Apache, this can be commented out
         - because the web server will log this information.
        -->
      <access-log path="logs/access.log"
            format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
            rollover-period="1W"/>

      <!-- creates the webapps directory for .war expansion -->
      <web-app-deploy path="webapps"/>

      <!-- creates the deploy directory for .ear expansion -->
      <ear-deploy path="deploy">
        <ear-default>
          <!-- configuration this for the ejb server
             -
             - <ejb-server>
             -   <config-directory>WEB-INF</config-directory>
             -   <data-source>jdbc/test</data-source>
             - </ejb-server>
            -->
        </ear-default>
      </ear-deploy>

      <!-- creates the deploy directory for .rar expansion -->
      <resource-deploy path="deploy"/>

      <!-- creates a second deploy directory for .war expansion -->
      <web-app-deploy path="deploy"/>
    </host-default>

    <!-- includes the web-app-default for default web-app behavior -->
    <resin:import path="${resinHome}/conf/app-default.xml"/>

    <!-- configures a deployment directory for virtual hosts -->
    <host-deploy path="hosts">
      <host-default>
        <resin:import path="host.xml" optional="true"/>
      </host-default>
    </host-deploy>

    <!-- configures the default host, matching any host name -->
    <host id="" root-directory=".">
      <!--
         - configures an explicit root web-app matching the
         - webapp's ROOT
        -->
      <web-app id="/" document-directory="E:\java\eclipse-jee-luna-SR2-win32-x86_64\workspace\resin\target\resin">
          <session-config>
             <session-max>1000</session-max>
             <session-timeout>30</session-timeout>
             <enable-cookies>true</enable-cookies>
             <enable-url-rewriting>true</enable-url-rewriting>
           </session-config>
      </web-app>
       
    </host>
  </server>
</resin>




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值