這裏有一個指南,向您展現如何使用「mvn site:deploy」來自動部署生成的文檔站點到服務器,這裏經過WebDAV機制說明。html
P.S 在這篇文章中,咱們使用的是Apache服務器2.x的WebDAV功能。web
請參見本指南,瞭解 如何啓用WebDAV訪問Apache 2.x服務器。apache
在 pom.xml 中,配置在 「distributionManagement」 標籤部署你的網站。windows
<distributionManagement>
<site>
<id>yiibaiserver</id>
<url>dav:http://127.0.0.1/sites/</url>
</site>
</distributionManagement>複製代碼
告訴Maven來使用「wagon-webdav-jackrabbit」擴展部署。bash
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
</build>複製代碼
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>複製代碼
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yiibai.core</groupId>
<artifactId>yiibai-core</artifactId>
<packaging>jar</packaging>
<version>1</version>
<name>yiibai-core</name>
<url>http://maven.apache.org</url>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
</build>
<distributionManagement>
<site>
<id>yiibaiserver</id>
<url>dav:http://127.0.0.1/sites/</url>
</site>
</distributionManagement>
</project>複製代碼
一般狀況下,WebDAV是須要認證的訪問。因此須要把相關的認證細節(用戶名和密碼)%MAVEN_PATH%/conf/settings.xml.服務器
<servers>
<server>
<id>yiibaiserver</id>
<username>admin</username>
<password>123456</password>
</server>
</servers>複製代碼
「mvn site:deploy」 命令執行:yii
C:\worksp\yiibai-core>mvn site:deploy
... ...
Transfer finished. 11622 bytes copied in 0.021 seconds
十一月 03, 2015 9:00:07 下午 org.apache.commons.httpclient.auth.AuthChallengePro
cessor selectAuthScheme
信息: digest authentication scheme selected
Uploading: .//project-info.html to http://127.0.0.1/sites/
##十一月 03, 2015 9:00:07 下午 org.apache.commons.httpclient.auth.AuthChallengeP
rocessor selectAuthScheme
信息: digest authentication scheme selected
##http://127.0.0.1/sites//./project-info.html - Status code: 201
Transfer finished. 11170 bytes copied in 0.035 seconds
十一月 03, 2015 9:00:07 下午 org.apache.commons.httpclient.auth.AuthChallengePro
cessor selectAuthScheme
信息: digest authentication scheme selected
Uploading: .//project-summary.html to http://127.0.0.1/sites/
##十一月 03, 2015 9:00:07 下午 org.apache.commons.httpclient.auth.AuthChallengeP
rocessor selectAuthScheme
信息: digest authentication scheme selected
##http://127.0.0.1/sites//./project-summary.html - Status code: 201
Transfer finished. 10190 bytes copied in 0.021 seconds
http://127.0.0.1/sites/ - Session: Disconnecting
http://127.0.0.1/sites/ - Session: Disconnected
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.737 s
[INFO] Finished at: 2015-11-03T21:00:07+08:00
[INFO] Final Memory: 14M/156M
[INFO] ------------------------------------------------------------------------複製代碼
全部站點文件夾和文件,在項目文件夾- 「target/site」會被自動部署到服務器。maven
在本例中,能夠經過這個網址訪問該部署的站點:http://127.0.0.1/sites/,見下圖:網站