ip696
ip696

Reputation: 7084

What way is better for use gradle BOM and spring-boot(multimodular application)

I use Gradle to build my spring-boot application. What do I want?

I have a multimodular application where some modules are spring-boot applications. I want to get BOM spring dependencies in the parent project's Gradle file and use all libraries without versions.

Now I have the next configs:

 buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        }
    }

apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

And I duplicate this code in each module. I read Gradle documentation and see this:

The plugin itself does not automatically apply the Spring Dependency Management plugin anymore. Instead it does react to the Spring Dependency Management plugin being applied and configured with the spring-boot-dependencies BOM (bill of materials. We will go into more detail about the BOM support later in this post.)

And there is an example below:

plugins {
    id 'java'
    id 'com.gradle.build-scan' version '1.16'
    id 'org.springframework.boot' version '2.0.5.RELEASE'
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE'
...

I'm confused. What variant is better? I try to change my code like this documentation and I get an error:

> Could not resolve all files for configuration ':my-server:compileClasspath'.
   > Could not find org.springframework.boot:spring-boot-starter-data-jpa:.
     Required by:
         project :my-server
   > Could not find org.springframework.boot:spring-boot-starter-cache:.
     Required by:
         project :my-server
   > Could not find org.springframework.boot:spring-boot-configuration-processor:.
     Required by:
         project :my-server
   > Could not find org.hibernate:hibernate-jpamodelgen:.
     Required by:
         project :my-server
   > Could not find org.projectlombok:lombok:.
     Required by:
         project :my-server
   > Could not find org.springframework.kafka:spring-kafka:.
     Required by:
         project :my-server

Upvotes: 1

Views: 1138

Answers (1)

user3038039
user3038039

Reputation: 66

You still need to define repositories for your dependencies. Add the below line to your build.gradle.

repositories {
    mavenCentral()
}

Upvotes: 0

Related Questions