好玩的大數(shù)據(jù)之22:Maven安裝(Maven-3.6.3)


一鸽疾、簡(jiǎn)介

Maven項(xiàng)目對(duì)象模型(POM)吊洼,可以通過(guò)一小段描述信息來(lái)管理項(xiàng)目的構(gòu)建,報(bào)告和文檔的項(xiàng)目管理工具軟件制肮。

Maven 除了以程序構(gòu)建能力為特色之外冒窍,還提供高級(jí)項(xiàng)目管理工具。由于 Maven 的缺省構(gòu)建規(guī)則有較高的可重用性豺鼻,所以常常用兩三行 Maven 構(gòu)建腳本就可以構(gòu)建簡(jiǎn)單的項(xiàng)目综液。由于 Maven 的面向項(xiàng)目的方法,許多 Apache Jakarta 項(xiàng)目發(fā)文時(shí)使用 Maven儒飒,而且公司項(xiàng)目采用 Maven 的比例在持續(xù)增長(zhǎng)意乓。

Maven這個(gè)單詞來(lái)自于意第緒語(yǔ)(猶太語(yǔ)),意為知識(shí)的積累,最初在Jakata Turbine項(xiàng)目中用來(lái)簡(jiǎn)化構(gòu)建過(guò)程届良。當(dāng)時(shí)有一些項(xiàng)目(有各自Ant build文件),僅有細(xì)微的差別圣猎,而JAR文件都由CVS來(lái)維護(hù)士葫。于是希望有一種標(biāo)準(zhǔn)化的方式構(gòu)建項(xiàng)目,一個(gè)清晰的方式定義項(xiàng)目的組成送悔,一個(gè)容易的方式發(fā)布項(xiàng)目的信息慢显,以及一種簡(jiǎn)單的方式在多個(gè)項(xiàng)目中共享JARs(摘自百度百科)

二、下載


下載地址:https://www.scala-sbt.org/download.html

三欠啤、安裝


????解壓縮

????tar zxvf?apache-maven-3.6.3-bin.tar.gz -C /mylab/soft

四荚藻、配置


???1.配置環(huán)境變量

? ? ? ? ? ? vi ~/.bashrc

#apache-maven-3.6.3

export MAVEN_HOME=$MYLAB_BASE_HOME/apache-maven-3.6.3

export PATH=$MAVEN_HOME/bin:$PATH

? ? 2.增加國(guó)內(nèi)maven源

?加速器,修改$MAVEN_HOME/conf文件夾下的settings.xml文件洁段,添加如下鏡像配置:

<mirrors>

? ? <mirror>

? ? ? <id>alimaven</id>

? ? ? <name>aliyun maven</name>

? ? ? <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

? ? ? <mirrorOf>central</mirrorOf>

? ? </mirror>

? </mirrors>

注:參考sbt加速中的地址应狱,不斷嘗試

五、驗(yàn)證


mvn -h

usage: mvn [options] [<goal(s)>] [<phase(s)>]

Options:

-am,--also-make? ? ? ? ? ? ? ? ? ? ? ? If project list is specified, also

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? build projects required by the

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? list

-amd,--also-make-dependents? ? ? ? ? ? If project list is specified, also

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? build projects that depend on

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? projects on the list

-B,--batch-mode? ? ? ? ? ? ? ? ? ? ? ? Run in non-interactive (batch)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? mode (disables output color)

-b,--builder <arg>? ? ? ? ? ? ? ? ? ? The id of the build strategy to

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? use

-C,--strict-checksums? ? ? ? ? ? ? ? ? Fail the build if checksums don't

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? match

-c,--lax-checksums? ? ? ? ? ? ? ? ? ? Warn if checksums don't match

-cpu,--check-plugin-updates? ? ? ? ? ? Ineffective, only kept for

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? backward compatibility

-D,--define <arg>? ? ? ? ? ? ? ? ? ? ? Define a system property

-e,--errors? ? ? ? ? ? ? ? ? ? ? ? ? ? Produce execution error messages

-emp,--encrypt-master-password <arg>? Encrypt master security password

-ep,--encrypt-password <arg>? ? ? ? ? Encrypt server password

-f,--file <arg>? ? ? ? ? ? ? ? ? ? ? ? Force the use of an alternate POM

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? file (or directory with pom.xml)

-fae,--fail-at-end? ? ? ? ? ? ? ? ? ? Only fail the build afterwards;

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? allow all non-impacted builds to

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? continue

-ff,--fail-fast? ? ? ? ? ? ? ? ? ? ? ? Stop at first failure in

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? reactorized builds

-fn,--fail-never? ? ? ? ? ? ? ? ? ? ? NEVER fail the build, regardless

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? of project result

-gs,--global-settings <arg>? ? ? ? ? ? Alternate path for the global

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? settings file

-gt,--global-toolchains <arg>? ? ? ? ? Alternate path for the global

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? toolchains file

-h,--help? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Display help information

-l,--log-file <arg>? ? ? ? ? ? ? ? ? ? Log file where all build output

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? will go (disables output color)

-llr,--legacy-local-repository? ? ? ? Use Maven 2 Legacy Local

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Repository behaviour, ie no use of

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? _remote.repositories. Can also be

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? activated by using

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -Dmaven.legacyLocalRepo=true

-N,--non-recursive? ? ? ? ? ? ? ? ? ? Do not recurse into sub-projects

-npr,--no-plugin-registry? ? ? ? ? ? ? Ineffective, only kept for

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? backward compatibility

-npu,--no-plugin-updates? ? ? ? ? ? ? Ineffective, only kept for

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? backward compatibility

-nsu,--no-snapshot-updates? ? ? ? ? ? Suppress SNAPSHOT updates

-ntp,--no-transfer-progress? ? ? ? ? ? Do not display transfer progress

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? when downloading or uploading

-o,--offline? ? ? ? ? ? ? ? ? ? ? ? ? Work offline

-P,--activate-profiles <arg>? ? ? ? ? Comma-delimited list of profiles

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? to activate

-pl,--projects <arg>? ? ? ? ? ? ? ? ? Comma-delimited list of specified

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? reactor projects to build instead

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? of all projects. A project can be

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? specified by [groupId]:artifactId

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? or by its relative path

-q,--quiet? ? ? ? ? ? ? ? ? ? ? ? ? ? Quiet output - only show errors

-rf,--resume-from <arg>? ? ? ? ? ? ? ? Resume reactor from specified

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? project

-s,--settings <arg>? ? ? ? ? ? ? ? ? ? Alternate path for the user

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? settings file

-t,--toolchains <arg>? ? ? ? ? ? ? ? ? Alternate path for the user

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? toolchains file

-T,--threads <arg>? ? ? ? ? ? ? ? ? ? Thread count, for instance 2.0C

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? where C is core multiplied

-U,--update-snapshots? ? ? ? ? ? ? ? ? Forces a check for missing

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? releases and updated snapshots on

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? remote repositories

-up,--update-plugins? ? ? ? ? ? ? ? ? Ineffective, only kept for

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? backward compatibility

-v,--version? ? ? ? ? ? ? ? ? ? ? ? ? Display version information

-V,--show-version? ? ? ? ? ? ? ? ? ? ? Display version information

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? WITHOUT stopping build

-X,--debug? ? ? ? ? ? ? ? ? ? ? ? ? ? Produce execution debug output

五祠丝、國(guó)內(nèi)倉(cāng)庫(kù)配置參考


網(wǎng)上收集了以下國(guó)內(nèi)maven倉(cāng)庫(kù)

<mirrors>

????????<mirror>

? ? ? ? ? ? <id>aliyun-maven</id>

? ? ? ? ? ? <name>阿里云公共倉(cāng)庫(kù)</name>

? ? ? ? ? ? <url>https://maven.aliyun.com/repository/public</url>

? ? ? ? ? ? <mirrorOf>public</mirrorOf>

? ? ? ? </mirror>

? ? ? ? <mirror>

? ? ? ? ? ? <id>alimaven</id>

? ? ? ? ? ? <name>aliyun maven</name>

? ? ? ? ? ? <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

? ? ? ? ? ? <mirrorOf>central</mirrorOf>

? ? ? ? </mirror>

? ? ? ? <mirror>

? ? ? ? ? ? <id>CN</id>

? ? ? ? ? ? <name>OSChina Central</name>

? ? ? ? ? ? <url>http://maven.oschina.net/content/groups/public/</url>

? ? ? ? ? ? <mirrorOf>central</mirrorOf>

? ? ? ? </mirror>

????????<mirror>

? ? ? ? ? ? <id>aliyun-google</id>

? ? ? ? ? ? <name>阿里云谷歌倉(cāng)庫(kù)</name>

? ? ? ? ? ? <url>https://maven.aliyun.com/repository/google</url>

? ? ? ? ? ? <mirrorOf>central</mirrorOf>

? ? ? ? </mirror>

????????<mirror>

? ? ? ? ? ? <id>aliyun-apache-snapshots</id>

? ? ? ? ? ? <name>阿里云阿帕奇?zhèn)}庫(kù)</name>

? ? ? ? ? ? <url>https://maven.aliyun.com/repository/apache-snapshots</url>

? ? ? ? ? ? <mirrorOf>central</mirrorOf>

? ? ? ? </mirror>

????????<mirror>

? ? ? ? ? ? <id>aliyun-spring</id>

? ? ? ? ? ? <name>阿里云spring倉(cāng)庫(kù)</name>

? ? ? ? ? ? <url>https://maven.aliyun.com/repository/spring</url>

? ? ? ? ? ? <mirrorOf>central</mirrorOf>

? ? ? ? </mirror>

? ? ? ? <mirror>

? ? ? ? ? ? <id>aliyun-spring-plugin</id>

? ? ? ? ? ? <name>阿里云spring插件倉(cāng)庫(kù)</name>

? ? ? ? ? ? <url>https://maven.aliyun.com/repository/spring-plugin</url>

? ? ? ? ? ? <mirrorOf>central</mirrorOf>

? ? ? ? </mirror>

</mirrors>

六疾呻、參考


http://www.reibang.com/p/d95d0b1b6975?讓maven使用國(guó)內(nèi)鏡像和archetypeCatalog

1.關(guān)于settings.xml

mvn -X

會(huì)有如下提示

[DEBUG] Reading global settings from /mylab/soft/apache-maven-3.6.3/conf/settings.xml

[DEBUG] Reading user settings from /home/hadoop/.m2/settings.xml

[DEBUG] Reading global toolchains from /mylab/soft/apache-maven-3.6.3/conf/toolchains.xml

[DEBUG] Reading user toolchains from /home/hadoop/.m2/toolchains.xml

[DEBUG] Using local repository at /home/hadoop/.m2/repository

[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /home/hadoop/.m2/repository

setting2.xml加入的以下內(nèi)容

<mirror>

? ? ? <id>alimaven</id>

? ? ? <name>aliyun maven</name>

? ? ? <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

? ? ? <mirrorOf>central</mirrorOf>? ? ? ?

</mirror>

里面有個(gè)<mirrorOf>central</mirrorOf>

代表的含義是

把我提供的這個(gè)阿里云的源當(dāng)作central源的代理吧,以后你需要訪問(wèn)那個(gè)名為central的源時(shí)写半,就把所有的請(qǐng)求轉(zhuǎn)發(fā)到我阿里云上岸蜗。

那么central又是什么呢?原來(lái)maven自己內(nèi)置了一個(gè)超級(jí)POM叠蝇,里面預(yù)先定義了名為central對(duì)應(yīng)的地址:

<repositories>

? <repository>

? ? <id>central</id>

? ? <name>Central Repository</name>

? ? <url>http://repo.maven.apache.org/maven2</url>

? ? <layout>default</layout>

? ? <snapshots>

? ? ? <enabled>false</enabled>

? ? </snapshots>

? </repository>

</repositories>

可以看到璃岳,central這個(gè)id對(duì)應(yīng)的是http://repo.maven.apache.org/maven2。

2.關(guān)于archetype-catalog.xml

http://repo.maven.apache.org/maven2/archetype-catalog.xml

下載

將archetype-catalog.xml保存到userhome/.m2文件夾

mvn時(shí)指定-DarchetypeCatalog=internal

即可使用maven默認(rèn)的archetype-catalog.xml悔捶,而不用再remote下載

通過(guò)以上設(shè)置铃慷,運(yùn)行以下命令就可以體驗(yàn)飛一樣的感覺(jué)

mvn archetype:generate\

-DgroupId=Group1\

-DartifactId=Flink-QuickStart-Scala\

-DarchetypeGroupId=org.apache.flink\

-DarchetypeArtifactId=flink-quickstart-scala\

-DinteractiveMode=false\

-DarchetypeVersion=1.11.1\

-DarchetypeCatalog=internal


其中archetypeCatalog用來(lái)指定maven-archetype-plugin讀取archetype-catalog.xml文件的位置:

internal:maven-archetype-plugin內(nèi)置的

local:mvn會(huì)使用本地的原型數(shù)據(jù)來(lái)供你選擇生成骨架原型

remote:指向maven中央倉(cāng)庫(kù)的Catalog


3.IDEA設(shè)置archetype-catalog.xml

打開(kāi)idea,點(diǎn)擊File——>settings——>Maven——>Runner——在Runner配置頁(yè)中的VM Options 中輸入

? ??????-DarchetypeCatalog=internal

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末炎功,一起剝皮案震驚了整個(gè)濱河市枚冗,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌蛇损,老刑警劉巖赁温,帶你破解...
    沈念sama閱讀 217,406評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異淤齐,居然都是意外死亡股囊,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,732評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門更啄,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)稚疹,“玉大人,你說(shuō)我怎么就攤上這事祭务∧诠罚” “怎么了怪嫌?”我有些...
    開(kāi)封第一講書人閱讀 163,711評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)柳沙。 經(jīng)常有香客問(wèn)我岩灭,道長(zhǎng),這世上最難降的妖魔是什么赂鲤? 我笑而不...
    開(kāi)封第一講書人閱讀 58,380評(píng)論 1 293
  • 正文 為了忘掉前任噪径,我火速辦了婚禮,結(jié)果婚禮上数初,老公的妹妹穿的比我還像新娘找爱。我一直安慰自己,他們只是感情好泡孩,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,432評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布车摄。 她就那樣靜靜地躺著,像睡著了一般珍德。 火紅的嫁衣襯著肌膚如雪练般。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書人閱讀 51,301評(píng)論 1 301
  • 那天锈候,我揣著相機(jī)與錄音薄料,去河邊找鬼。 笑死泵琳,一個(gè)胖子當(dāng)著我的面吹牛摄职,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播获列,決...
    沈念sama閱讀 40,145評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼谷市,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了击孩?” 一聲冷哼從身側(cè)響起迫悠,我...
    開(kāi)封第一講書人閱讀 39,008評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎巩梢,沒(méi)想到半個(gè)月后创泄,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,443評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡括蝠,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,649評(píng)論 3 334
  • 正文 我和宋清朗相戀三年鞠抑,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片忌警。...
    茶點(diǎn)故事閱讀 39,795評(píng)論 1 347
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡搁拙,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情箕速,我是刑警寧澤酪碘,帶...
    沈念sama閱讀 35,501評(píng)論 5 345
  • 正文 年R本政府宣布,位于F島的核電站弧满,受9級(jí)特大地震影響婆跑,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜庭呜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,119評(píng)論 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望犀忱。 院中可真熱鬧募谎,春花似錦、人聲如沸阴汇。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,731評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)搀庶。三九已至拐纱,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間哥倔,已是汗流浹背秸架。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 32,865評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留咆蒿,地道東北人东抹。 一個(gè)月前我還...
    沈念sama閱讀 47,899評(píng)論 2 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像沃测,于是被迫代替她去往敵國(guó)和親缭黔。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,724評(píng)論 2 354