How to include transiant depedency of springboot inside fabric mod

Hey, I’m working on a mod with Fabric Mc and I want to use Spring inside.
So to achieve that I have made this build.gradle config :

plugins {
	id 'fabric-loom' version '0.11-SNAPSHOT'
	id 'org.springframework.boot' version '2.5.4'
	id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
	// Add repositories to retrieve artifacts from in here.
	// You should only use this when depending on other mods because
	// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
	// See https://docs.gradle.org/current/userguide/declaring_repositories.html
	// for more information about repositories.
	maven { url 'https://jitpack.io' }
	maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
	maven { url 'https://mvnrepository.com/artifac' }
	maven { url 'https://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-releases' }
	maven { url 'https://maven.terraformersmc.com/releases' }
	mavenCentral()
}

configurations {
	springBom
	compileOnly.extendsFrom(springBom)
	annotationProcessor.extendsFrom(springBom)
	implementation.extendsFrom(springBom)
	all {
		// We need to use fabric implementation of log4j
		exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
	}
}

dependencies {
	// To change the versions see the gradle.properties file
	minecraft "com.mojang:minecraft:${project.minecraft_version}"
	mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

	// Fabric API. This is technically optional, but you probably want it anyway.
	modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

	// Spring boot dependencies
	springBom enforcedPlatform('org.springframework.boot:spring-boot-dependencies:2.5.4.RELEASE')

	api include('org.springframework.boot:spring-boot-starter')
	implementation include('org.springframework.boot:spring-boot-dependencies:2.5.4.RELEASE')
	implementation include('org.springframework.boot:spring-boot-starter-web')
	implementation include('org.springframework.boot:spring-boot-starter-websocket')

	// OpenAPI swagger
	implementation include('org.springdoc:springdoc-openapi-ui:1.6.13')

	// Spring discord api
	implementation include('com.discord4j:discord4j-core:3.2.3')
}

processResources {
	inputs.property "version", project.version

	filesMatching("fabric.mod.json") {
		expand "version": project.version
	}
}

tasks.withType(JavaCompile).configureEach {
	it.options.release = 17
}

java {
	// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
	// if it is present.
	// If you remove this line, sources will not be generated.
	withSourcesJar()
}

And it works while I run it with Gradle. But when I try to generate the jar, I don’t get transient dependency of spring and that result on this error when I run from the jar :

java.lang.RuntimeException: Could not execute entrypoint stage 'server' due to errors, provided by 'litopia_services'!
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
       at fr.litopia.services.LitopiaServices.onInitializeServer(LitopiaServices.java:23) ~[litopia-services-1.0.0.jar:?]

So, how can I correctly include the spring boot dependency inside my build jar?

You should probably use the result of bootJar when using Spring Boot, which will be a fat jar built the good way.
If you use the jar result, you have a jar with just your code in it.

Btw. some sidenotes from skimming over your build script:

  • Do not use the Spring Dependency Management plugin, it is just a left-over from a time where Gradle had no built-in BOM support. Actually you even do not use it, you use the built-in BOM support, but still apply the dependency management plugin uselessly
  • Consider using Java Toolchains feature instead of settings the compatibilities, then the version you use to run Gradle is decoupled from the version needed to compile your sources
  • For version = project.mod_version and group = project.maven_group I guess you set mod_version and maven_group in gradle.properties? If so, just set version and group directly in there instead of in the build script.
  • Do not use JitPack like that. That is, as first repository and without repository content filter. JitPack is imho broken by design when it comes to publishing projects. Unfortunatley some projects are too lazy to set up proper publishing and rely on their users using it, but I strongly advice to use a repository content filter to define exactly what to take from there and what not, because JitPack besides being a PITA and unreliable, it is also slow as hell and thus will majorly slow down your builds. So even if you do not want to use a repository content filter, at least use it as last repository, not as first.

Thanks for your response!
I have followed your advice, but there is multiple problem when I try your solution.
First the boot run jar create effectively a big jar with all required library, but because it did not generate by build it doesn’t include the JSON files and remapped version of Minecraft, and it doesn’t include mod Implementation required by Fabric API. So, It will not detect my jar as a mod.
Secondly, when I remove the Spring Bom from build.gradle I can’t run my mod at all in debug mod because it did not find spring boot dependency. This is the error that I get :

Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find org.springframework.boot:spring-boot-starter-web:.
     Required by:
         project :
   > Could not find org.springframework.boot:spring-boot-starter-websocket:.
     Required by:
         project :

So, I think I need to merge bootjar and build to make a functional chimera.
Did you think this is possible?

I didn’t say you should remove the bom.
I said you should not apply the legacy spring dependency management Gradle plugin, especially as you already consume the bom using the built-in way.

I do neither Spring Boot development, nor Minecraft development, nor do I know your project, so I cannot really advice on how to achieve what you want. Just telling that the normal jar is just a jar with your code and no dependencies, just how it should be, and that the bootJar task is building a fat jar with everything inside. The boot jar should usually contain all your normal jar is also containing.