2014-03-06 230 views
2

我是Git和Maven的新手。Maven Git倉庫

我需要通過Maven購買在git倉庫中獲取maven項目來構建war文件。

目前我有本地git倉庫中的maven項目,我在項目根目錄上運行mvn tomcat7:deploy命令來建立並部署它在tomcat服務器上,並且我成功了。

但我想知道如何從遠程git存儲庫獲取maven項目並更新本地git存儲庫並構建war文件。

我現在的pom.xml的是這樣的

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 
     <source>1.6</source> 
     <target>1.6</target> 
    </configuration> 
    </plugin> 
    <plugin> 
    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat7-maven-plugin</artifactId> 
    <version>2.0</version> 
    <configuration> 
     <url>http://localhost:8080/manager/text</url> 
     <server>TomcatServer</server> 
     <path>/Test</path> 
    </configuration> 
    </plugin> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-war-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 
     <failOnMissingWebXml>false</failOnMissingWebXml> 
    </configuration> 
</plugin> 
    <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>buildnumber-maven-plugin</artifactId> 
     <version>1.2</version> 
     <executions> 
     <execution> 
      <phase>validate</phase> 
      <goals> 
       <goal>create</goal> 
      </goals> 
     </execution> 
     </executions> 
     <configuration> 
      <docheck>true</docheck> 
      <doupdate>true</doupdate> 
      <shortrevisionlength>5</shortrevisionlength> 
     </configuration> 
    </plugin> 
    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.poi</groupId> 
     <artifactId>poi-ooxml</artifactId> 
     <version>3.9</version> 
    </dependency> 
    </dependencies> 
    <scm> 
     <connection>scm:git:git://ServerIP/Repository</connection> 
     <developerConnection>scm:git:git://ServerIP/Repository</developerConnection> 
     <url>scm:git:git://ServerIP/Repository</url> 
    </scm> 

回答

0

你的意思是比如當你做一個mvn clean install你希望一切都由Maven一步完成。也就是說,不僅要有maven來構建和部署代碼,還要讓它從git中獲取最新版本的代碼,然後構建,部署。

如果是這樣,則情況看看這裏:How can I do a git pull in Maven?

+0

感謝它幫了我。我從上面理解的是,首先我將運行mvn scm:checkout並拉動存儲庫,然後運行mvn tomcat7:deploy來構建和部署。或者,如果我只是運行mvn clean install就足夠了。 – user3072043

+0

還沒有嘗試與服務器應用程序,所以我不能確定。 – zlinks

+0

我嘗試了mvn scm:checkout命令,但是它向我拋出致命錯誤:讀取錯誤:無效參數致命:邊帶解複用器中的錯誤。但是我能夠使用toolkit Git從遠程存儲庫中獲取並簽出。但通過maven面臨上述錯誤。 – user3072043

0

如果運行mvn clean install你應該找到的.war在「目標」文件夾