Here is a guide that shows you how to use “MVN site:deploy” to automatically deploy the generated document site to the server, illustrated via the WebDAV mechanism.
P.S. In this article, we use the WebDAV feature of Apache server 2.x.
1. Enable WebDAV
See this guide to learn how to enable WebDAV to access the Apache 2.x server.
2. Where to deploy the configuration
In Pom.xml, configure to deploy your site under the “distributionManagement” TAB.
< distributionManagement > < site > < id > yiibaiserver < id > < url > dav: http://127.0.0.1/sites/ < url > < site > </distributionManagement>Copy the code
The “dav” prefix was added before the HTTP protocol, which means deploying your web site through the WebDAV mechanism. Alternatively, you can replace it with “SCP” if your server supports “SCP” access.
Tell Maven to use the “wagon- Webdv-JackRabbit” extension deployment.
<build> <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId> Wagon - webdv-JackRabbit </artifactId> <version>1.0-beta-7</version> </extension> </extensions> </build>Copy the code
Some people say you can use “wagon webdav”, but it’s not that I tried it and it didn’t work, so use “wagon webdav-JackRabbit” instead.
<extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-webdav</artifactId> 1.0 beta - < version > 2 < / version > < / extension >Copy the code
<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 >Copy the code
3. Configure WebDAV authentication
Typically, WebDAV is access that requires authentication. %MAVEN_PATH%/conf/settings.xml.
<servers>
<server>
<id>yiibaiserver</id>
<username>admin</username>
<password>123456</password>
</server>
</servers>Copy the code
The “settings. XML” file server ID in Maven will be referenced by websites in the “pom.xml” file.
4. mvn site:deploy
The “MVN site:deploy” command is executed:
C:\worksp\yiibai-core>mvn site:deploy ... . Transfer finished. 11622 bytes copiedin0.021 seconds on November 3, 2015 org.apache.com mons 9:00:07 afternoon. Httpclient. Auth. AuthChallengePro cessor selectAuthScheme information: Digest Authentication scheme selected Uploading:.//project-info.html to http://127.0.0.1/sites/# # 3 November, 2015 org.apache.com mons 9:00:07 afternoon. Httpclient. The auth. AuthChallengePRocessor selectAuthScheme Information: Digest Authentication Scheme selected# # http://127.0.0.1/sites//./project-info.html - the Status code: 201
Transfer finished. 11170 bytes copied in0.035 seconds on November 3, 2015 org.apache.com mons 9:00:07 afternoon. Httpclient. Auth. AuthChallengePro cessor selectAuthScheme information: Digest Authentication scheme selected Uploading:.//project-summary. HTML to http://127.0.0.1/sites/# # 3 November, 2015 org.apache.com mons 9:00:07 afternoon. Httpclient. The auth. AuthChallengePRocessor selectAuthScheme Information: Digest Authentication Scheme selected# # http://127.0.0.1/sites//./project-summary.html - the 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] ------------------------------------------------------------------------Copy the code
All site folders and files in the project folder – “target/site” will be automatically deployed to the server.
5. The output
In this case, the deployment site can be accessed via this url: http://127.0.0.1/sites/, as shown below:
Complete project source code