Maven总结

Maven目录结构

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模板

<!--下载源码和javadoc-->

<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>

<!--把依赖包导出到lib文件夹-->

<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>

 

 

<!--跳过单元测试,相当于 eclipse maven install -DskipTests-->

<plugin>

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

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

<configuration>

<skip>true</skip>

</configuration>

</plugin>  

</plugins>

</build>

 

 

Maven创建项目脚本

#!/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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值