Eclipse中配置resin 4.x


  開發web項目時,你還困擾在,反復啟動web容器的痛苦中么?也許會有人說,用調試模式。但是如果涉及到配置文件或者service類,還是不得不重啟web容器吧,而且偶爾會出現抽風情況,沒生效的情況(這時候會讓你覺得到底是沒生效?還是代碼有問題?是不是很糾結)。

下面介紹下resin在開發web項目時的方便之處

  除非修改web.xml文件,其他的java文件修改,resin會自動刷新--類似於熱部署 不再需要重啟web容器就能得到最新代碼環境---可謂為開發節約了大部分時間

  平時的開發中建議resin和tomcat並用。做eclipse詳細調試的時候用tomcat(當然也可以用resin做這個功能),做web調試的時候用resin比較方便,下面詳細說說eclipse中resin配置吧

 

 對於Resin的調試模式網上介紹的相當的少,幾乎沒有什么帖子或者文章介紹Eclipse和Resin的整合,大多都是簡單的寫了Eclipse無插件方式啟動Resin,關於調試模式的啟動都是簡單的幾個命令就結束了,並沒有像Tomcat那樣順手! 
  花了很長時間尋找一個整合方法,最終還是發現了: 

 

  當然了,能看到界面就說明 --> 這個肯定是用了插件的 后面介紹 Resin官方主推的插件 
  之前你需要一個對應的 Resin版本,下載地址:http://www.caucho.com/download/ 

  插件安裝:http://caucho.com/eclipse 

 

能看到這段文字就說明這個網址沒有問題,可以作為 Eclipse插件源進行更新 
打開Eclipse選擇 Help -> Software Updates... 點擊右邊的 Add site... 
在彈出來的對話框中輸入 http://caucho.com/eclipse (注意刪了空格) 

 

不知什么原因我更新后顯示的名字就變樣了,這個自己摸索下也能弄懂的 
添加站點后點開左邊的樹選擇 Resin 然后右上角的 Install就會變亮(我的安裝了所以暗着) 



OK 后面就是聯網下載更新插件了... (看到這里,如果你說你沒有互聯網,那我就什么都不說了,趕緊找榔頭把電腦砸了吧...) 

window - show view - servers 顯示出來服務器框 
然后在 servers框中點右鍵 new 一個服務器這時候就會出現最上面第一張圖片的Resin,選擇你自己需要的版本... 這里只管 3和4 用2的... 2就2吧 沒辦法 2的人已經被埋沒了... 哈哈! 

Resin 3.1 以及 temporary directory deploy 都是先將項目打包war然后復制到項目的發布文件夾中(位於你項目的workspace下面的.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps 文件夾中)缺點,更換項目進行開發的時候原有的war文件不會被刪除... 需要手動刪除 

另外一個(in space)就是不打包直接復制到發布目錄中並將項目發布 (推薦) 

安裝的第二部需要選擇jdk環境,這個自己選擇了,或者選系統的 或者自己指定 
第三步需要指定你解壓縮后的 Resin 文件夾(上面說的下載的文件,建議解壓到D盤下比如 D:\Resin) 

我原來有一個Tomcat的服務器,后面又嘗試了2個不同的 Resin 



這里就顯示了3個啟動服務器,當然需要使用哪個版本運行就先選擇 然后點右邊的綠色運行按鈕! 

 

 

=============================華麗分割線============================================

1、注意eclipse需要3.6以上版本才能支持。

 

2、對於resin 4.x配置后 啟動會報錯 

'default' is an unknown server in the configuration file.

 

 

3、配置resin.xml文件

<!--
   - Resin 4.0 configuration file.
  -->
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="urn:java:com.caucho.resin">

  <!-- property-based Resin configuration -->
  <resin:properties path="${__DIR__}/resin.properties" optional="true"/>
  <resin:properties path="cloud:/resin.properties"
                    optional="true" recover="true"/>


  <resin:if test="${properties_import_url}">
     <resin:properties path="${properties_import_url}"
                    optional="true" recover="true"/>
  </resin:if>


  <!-- Logging configuration for the JDK logging API -->
  <log-handler name="" level="all" path="stdout:"
               timestamp="[%y-%m-%d %H:%M:%S.%s]"
               format=" {${thread}} ${log.message}"/>
               
  <!-- 
     - Alternative pseudo-TTCC log format
     -
     - <log-handler name="" level="all" path="stdout:"
     -           timestamp="%y-%m-%d %H:%M:%S.%s"
     -           format=" [${thread}] ${log.level} ${log.shortName} - ${log.message}"/>
    -->
   
  <!--
     - level='info' for production
     - 'fine' or 'finer' for development and troubleshooting
    -->
  <logger name="" level="${log_level?:'info'}"/>

  <logger name="com.caucho.java" level="config"/>
  <logger name="com.caucho.loader" level="config"/>

  <!--
     - Default configuration applied to all clusters, including
     - HTTP, HTTPS, and /resin-admin configuration.
    -->
  <resin:import path="${__DIR__}/cluster-default.xml"/>
  
  <!--
     - health configuration
    -->
  <resin:import path="${__DIR__}/health.xml"/>

  
  <!--
     - Remote management requires at least one enabled admin user.
    -->
  <resin:AdminAuthenticator>
    <user name="${admin_user}" password="${admin_password}"/>
    
    <resin:import path="${__DIR__}/admin-users.xml" optional="true"/>
    <resin:import path="cloud:/admin-users.xml" optional="true" recover="true"/>
  </resin:AdminAuthenticator>

  <!--
     - For clustered systems, create a password in as cluster_system_key
    -->
  <cluster-system-key>${cluster_system_key}</cluster-system-key>

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

  <!-- For resin.properties dynamic cluster joining -->
  <home-cluster>${home_cluster}</home-cluster>
  <home-server>${home_server}</home-server>
  <elastic-server>${elastic_server}</elastic-server>
  <elastic-dns>${elastic_dns}</elastic-dns>

  <!--
     - Configures the main application cluster.  Load-balancing configurations
     - will also have a web cluster.
    -->
  <cluster id="app">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="app-" address-list="${app_servers}" port="6800"/>

    <host-default>
      <!-- creates the webapps directory for .war expansion -->
      <web-app-deploy path="webapps"
                      expand-preserve-fileset="WEB-INF/work/**"
                      multiversion-routing="${webapp_multiversion_routing}"
                      path-suffix="${elastic_webapp?resin.id:''}"/>
    </host-default>

    <!-- auto virtual host deployment in hosts/foo.example.com/webapps -->
    <host-deploy path="hosts">
      <host-default>
        <resin:import path="host.xml" optional="true"/>
      </host-default>
    </host-deploy>

    <!-- the default host, matching any host name -->
    <!-- <host id="" root-directory=".">
      <web-app id="/" root-directory="webapps/ROOT"/>
      
      <resin:if test="${resin_doc}">
        <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/>
      </resin:if>
    </host> -->
    
    <!-- *******************************Site Start******************************* -->
    
    <!--
    <host id="test.com" root-directory="${resin.root}/webapps/test">
          <host-alias>test.com</host-alias>
          <web-app id="/"></web-app>
    </host>
    
-->
    <host id="www.xxxx.com" root-directory="${resin.root}/webapps/xxx-demo">
          <web-app id="/"></web-app>
    </host>
    
    <!-- *******************************Site End******************************* -->
    
  </cluster>

  <cluster id="web">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="web-" address-list="${web_servers}" port="6810"/>

    <host id="" root-directory="web">
      <web-app id="">
        <resin:LoadBalance regexp="" cluster="app"/>
      </web-app>
    </host>
  </cluster>

  <cluster id="memcached" xmlns:memcache="urn:java:com.caucho.memcached">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="memcached-" address-list="${memcached_servers}" port="6820">
      <!-- listen for the memcache protocol -->
      <listen port="${memcached_port?:11211}"
              keepalive-timeout="600s" socket-timeout="600s">
        <memcache:MemcachedProtocol/>
      </listen>
    </server-multi>
  </cluster>
  
</resin>

 

 

4、配置host文件

詳細目錄:C:\WINDOWS\system32\drivers\etc\hosts

在該文件后加

127.0.0.1       www.xxxx.com

 

5、直接可以在瀏覽器中輸入

http://www.xxxx.com:8080/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM