Maven總結(jié)

Maven目錄結(jié)構(gòu)

http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html



maven基本命令

mvn eclipse:eclipse #生成java項目

mvn eclipse:eclipse -Dwtpversion=1.0 #生成web項目

mvn install -DskipTests #跳過測試

mvn install:install-file -DgroupId=cloud-sign-utils -DartifactId=cloud-sign-utils -Dversion=1.0 -Dpackaging=jar -Dfile=cloud-sign-utils.jar #安裝某jar包到本地



下載源碼和javadoc命令

mvn install -DdownloadSource=true

mvn install -DdownloadSources=true


mvn dependency:sources

mvn dependency:resolve -Dclassifier=javadoc


配置eclipse

Window > Preferences > Maven and checking the "Download Artifact Sources" and "Download Artifact JavaDoc" options



pom.xml模板


<profiles> ?

<profile> ?

<id>downloadSources</id> ?

<properties> ?

<downloadSources>true</downloadSources> ?

<downloadJavadocs>true</downloadJavadocs> ????????????

</properties> ?

</profile> ?

</profiles>


<activeProfiles> ?

??<activeProfile>downloadSources</activeProfile> ?

</activeProfiles>



<!--deploy-->

<distributionManagement>

<repository>

<id>releases</id>

<name>Internal Releases</name>

<url>http://117.122.226.252:8081/nexus/content/repositories/releases/</url>

</repository>

<snapshotRepository>

<id>snapshots</id>

<name>Internal Snapshots</name>

<url>http://117.122.226.252:8081/nexus/content/repositories/snapshots/</url>

</snapshotRepository>

</distributionManagement> ?



<build>

<plugins>


<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-dependency-plugin</artifactId>

<executions>

<execution>

<id>copy</id>

<phase>install</phase>

<goals>

<goal>copy-dependencies</goal>

</goals>

<configuration>

<outputDirectory>

${project.build.directory}/lib

</outputDirectory>

</configuration>

</execution>

</executions>

</plugin>




<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-surefire-plugin</artifactId>

<configuration>

<skip>true</skip>

</configuration>

</plugin> ?

</plugins>

</build>



Maven創(chuàng)建項目腳本

#!/bin/bash

#項目中文名稱

#項目英文名


while read line;do

????eval "$line"

done < config


echo $projectNameCn

echo $projectName

# echo $MVN_HOME


#maven-archetype-quickstart (Java Project)

mvn archetype:generate -DgroupId=$projectName'-parent' -DartifactId=$artifactId'-parent' -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=local

# groupId:包名 ????????? artifactId:項目名 ???archetypeArtifactId:項目類型(模板) ?????????????interactiveMode:交互模式(默認:true)


# maven-archetype-webapp (Java Web Project)

mvn archetype:generate -DgroupId=$projectName'-app' -DartifactId=$projectName'-app' -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false -DarchetypeCatalog=local


cd $projectName'-parent'

rm -rf src

sed -i "s/<packaging>jar<\/packaging>/<packaging>pom<\/packaging>/g" pom.xml

sed -i '/<dependencies>/i<description>'$projectNameCn'<\/description>' pom.xml

sed -i '/<\/dependencies>/a<modules>\n\t<module>../'$projectName'-app-interface<\/module>\n\t<module>../'$projectName'-app-service<\/module>\n\t<module>../'$projectName'-app<\/module>\n<\/modules>' pom.xml

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容