描述

  1. 坐标:gradle工程所有jar包的坐标都在dependencies属性内放置,每一个jar包的坐标都有三个基本元素组成:group、name、version
  2. 作用域:
    • testImplementation:jar包在测试的时候起作用
    • compileOnly,
    • implementation
  1. buildscript {
  2. ext {
  3. springBootVersion = '2.1.2.RELEASE'
  4. }
  5. repositories {
  6. mavenCentral()
  7. }
  8. dependencies {
  9. classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  10. }
  11. }
  12. apply plugin: 'java'
  13. apply plugin: 'org.springframework.boot'
  14. apply plugin: 'io.spring.dependency-management'
  15. group = 'com.szk'
  16. version = '0.0.1-SNAPSHOT'
  17. sourceCompatibility = '1.8'
  18. repositories {
  19. mavenCentral()
  20. }
  21. configurations {
  22. compile.exclude group: 'org.springframework.boot',module:'spring-boot-starter-tomcat'
  23. }
  24. dependencies {
  25. implementation 'org.springframework.boot:spring-boot-starter-actuator'
  26. implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
  27. implementation 'org.springframework.boot:spring-boot-starter-web'
  28. implementation 'org.springframework.boot:spring-boot-starter-undertow'
  29. implementation 'mysql:mysql-connector-java'
  30. compileOnly 'org.projectlombok:lombok'
  31. testImplementation 'org.springframework.boot:spring-boot-starter-test'
  32. }

本地仓库搭建

  1. 加入环境变量(windows):GRADLE_USER_HOME
  2. 加入mavenLocal()
  1. buildscript {
  2. ext {
  3. springBootVersion = '2.1.2.RELEASE'
  4. }
  5. repositories {
  6. mavenLocal()
  7. mavenCentral()
  8. }
  9. dependencies {
  10. classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  11. }
  12. }