如果我們要使用spring mvc必須添加依賴荧库,以前我們是在項(xiàng)目的pom.xml進(jìn)行依賴的添加霹俺。下面我們看看gradle是如何添加的脖阵。
首先我們?nèi)aven倉庫找到我們需要的依賴包拇派。
QQ截圖20180521214345.png
QQ截圖20180521214425.png
添加到我們的build.gradle文件里面去拍屑。
QQ截圖20180521215037.png
格式:compile group: '組織機(jī)構(gòu)' , name: '項(xiàng)目名' , version: '版本號(hào)'
簡(jiǎn)化一下:
QQ截圖20180521215419.png
是不是很簡(jiǎn)潔途戒?
格式:
compile "組織機(jī)構(gòu):項(xiàng)目名:版本號(hào)"
注意簡(jiǎn)化版是" ",兩個(gè)點(diǎn)哈僵驰。
依賴code:
compile "org.springframework:spring-core:5.0.6.RELEASE"
compile "org.springframework:spring-web:5.0.6.RELEASE"
compile "org.springframework:spring-webmvc:5.0.6.RELEASE"
compile "org.springframework:spring-aop:5.0.6.RELEASE"
compile "org.springframework:spring-jdbc:5.0.6.RELEASE"
compile "org.springframework:spring-context-support:5.0.6.RELEASE"
有沒有發(fā)現(xiàn)如果有一天我需要改一下版本號(hào)喷斋,是不是每個(gè)都要改一下檩帐。是不是很麻煩损姜。是的,我們還可以簡(jiǎn)化一下曾掂。
QQ截圖20180521221537.png
code:
ext {
springVersion = "5.0.6.RELEASE"
}
dependencies {
testCompile "junit:junit:4.12"
compile "org.springframework:spring-core:${springVersion}"
compile "org.springframework:spring-web:${springVersion}"
compile "org.springframework:spring-webmvc:${springVersion}"
compile "org.springframework:spring-aop:${springVersion}"
compile "org.springframework:spring-jdbc:${springVersion}"
compile "org.springframework:spring-context-support:${springVersion}"
}