描述
- 坐标:gradle工程所有jar包的坐标都在dependencies属性内放置,每一个jar包的坐标都有三个基本元素组成:group、name、version
- 作用域:
- testImplementation:jar包在测试的时候起作用
- compileOnly,
- implementation
buildscript { ext { springBootVersion = '2.1.2.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }}apply plugin: 'java'apply plugin: 'org.springframework.boot'apply plugin: 'io.spring.dependency-management'group = 'com.szk'version = '0.0.1-SNAPSHOT'sourceCompatibility = '1.8'repositories { mavenCentral()}configurations { compile.exclude group: 'org.springframework.boot',module:'spring-boot-starter-tomcat'}dependencies { implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-undertow' implementation 'mysql:mysql-connector-java' compileOnly 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test'}
本地仓库搭建
- 加入环境变量(windows):GRADLE_USER_HOME
- 加入mavenLocal()
buildscript { ext { springBootVersion = '2.1.2.RELEASE' } repositories { mavenLocal() mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }}