2014-01-25 12 views

回答

2

現在無法使用追加devserver單獨完成自動更新。嚴格地說,我們需要等待。

但是,您可以使用下面的配置實現無縫html/js/css/etc更新,熱門java代碼替換等的效果。

  1. 配置Apache httpd或Nginx直接從war-source提供靜態代碼,然後路由到servlet的應用引擎。在我的情況下,所有的html都可以從webapp目錄直接訪問,servlet通過/ sim /調用。使用nginx的和7070端口,我的工作nginx的配置是這樣的:

    server { 
        listen 7070; 
    
        root /home/pchauhan/Projects/my-company/my-mvn-gae-project/my-mvn-gae-project-war/src/main/webapp; 
    
        location /sim/ { 
         proxy_pass http://localhost:8080/sim/; 
        } 
    } 
    

使用this Nginx的文檔,以獲取更多的配置。

分別配置Eclipse和GAE。

  1. 現在,您可以直接對源代碼進行更改,並在html(通過nginx)和servlet(通過devserver)上刷新它們。
  2. 將此webapp文件夾添加到您的Chrome開發工具,源代碼工作區,生活會更容易。小的變化可以直接從Chrome保存通過CTRL上傳之前SRC

請注意,雖然這是偉大的,你應該測試您的應用程序,一旦僅8080(devserver端口),以防萬一有一個bug在maven配置和目標沒有正確創建/服務。

備用思路同步:如果你不想使用nginx的/ httpd的出於某種原因,你可以添加目標... web應用到工作區中鉻,工作有直接無縫UPDT然後用lsyncd同步目標回到src。我還沒有嘗試過,但看起來可行,儘管有點風險。

0

與PoojaC20一樣,我也無法單獨與devserver一起工作,但我最終得到了一個不同的解決方法,我認爲我會分享以防別人發現它有幫助。

我現在通過使用grunt-serve託管我的開發靜態文件在GAE devserver之外。這允許有許多優點,包括:

  1. 當靜態文件發生變化時自動刷新頁面 - 甚至不需要按刷新按鈕。
  2. 如javascript,可編譯語言的LESS
  3. 自動轉換,如CoffeeScript的
  4. 機制縮小和CDN-ification先進的CSS自動轉換時,開發完成。

上述最深刻的含義是,我必須移動從基於會話的認證到OAuth或ID連接的身份驗證系統路程,讓所有我的web服務的調用CORS兼容需要。這是一些工作,但它也有一個很深刻的優勢:

  1. 一旦你的網絡服務器已經轉移到基於ID連接的認證,它現在同樣連接到本地(例如手機)的客戶端或基於Web的客戶端!
2

到目前爲止,我發現的最佳方式是在pom.xml中配置下面的條目。這將自動生成您的靜態文件並反映在頁面上。

<plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.7</version> 
      <executions> 
       <execution> 
        <phase>process-classes</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <target> 
          <property name="target.webapp.dir" 
           value="${project.build.directory}/${project.build.finalName}" /> 
          <property name="src.webapp.dir" value="${basedir}/src/main/webapp" /> 

          <sync verbose="true" todir="${target.webapp.dir}" 
           includeEmptyDirs="true"> 
           <fileset dir="${src.webapp.dir}" /> 
           <preserveintarget> 
            <include name="WEB-INF/lib/**" /> 
            <include name="WEB-INF/classes/**" /> 
            <include name="WEB-INF/appengine-generated/**" /> 
           </preserveintarget> 
          </sync> 

          <!-- <sync verbose="true" todir="${target.webapp.dir}/WEB-INF/classes"> 
           <fileset dir="${basedir}/target/classes" /> </sync> --> 

         </target> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

而且

<pluginManagement> 
     <plugins> 
      <!-- This plugin's configuration is used to store Eclipse m2e settings 
       only. It has no influence on the Maven build itself. --> 
      <plugin> 
       <groupId>org.eclipse.m2e</groupId> 
       <artifactId>lifecycle-mapping</artifactId> 
       <version>1.0.0</version> 
       <configuration> 
        <lifecycleMappingMetadata> 
         <pluginExecutions> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId>org.apache.maven.plugins</groupId> 
            <artifactId>maven-antrun-plugin</artifactId> 
            <versionRange>[1.6,)</versionRange> 
            <goals> 
             <goal>run</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <execute> 
             <runOnIncremental>true</runOnIncremental> 
            </execute> 
           </action> 
          </pluginExecution> 
         </pluginExecutions> 
        </lifecycleMappingMetadata> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 

這是工作的罰款後,另一項。只要任何靜態文件改變並保存,就會反映在頁面上。

+0

我不明白這個配置如何允許熱部署。 – rds

+0

感謝您的配置。這個對我有用 – Hawk

相關問題