[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"global-header-tutorials-static":3,"article-spring-boot-create-libraries-gradle":4,"initial-similar-fetch":23},[],{"alias":5,"title":6,"description":7,"content":8,"thumbnail":9,"keywords":10,"categories":18,"tags":21,"createdAt":22},"spring-boot-create-libraries-gradle","Building Reusable Spring Boot Libraries with Gradle","Architectural Guide: Building Reusable Spring Boot Libraries with Gradle","{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"In this tutorial, we are going to learn how to package the Spring Boot project as a reusable library.\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"By default, Spring Boot is configured to package everything into a fat JAR file that contains all the dependencies and loader classes. \"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"To create our project as a library, we need to disable the fat JAR creation by creating a normal JAR file that only contains the project’s own classes and property files.\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"If you are creating the multi-project build parent application, please consider following our tutorial.\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"marks\":[{\"type\":\"link\",\"attrs\":{\"href\":\"https:\u002F\u002Fcsbyte.com\u002Fblog\u002Fmulti-build-project-gradle-spring-boot\",\"target\":\"_blank\",\"rel\":\"noopener noreferrer nofollow\",\"class\":null,\"title\":null}}],\"text\":\"Setting up a multi-project build in Gradle for Spring Boot\"}]},{\"type\":\"heading\",\"attrs\":{\"textAlign\":null,\"level\":2},\"content\":[{\"type\":\"text\",\"text\":\"Create a Spring Boot project\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"You can use a \"},{\"type\":\"text\",\"marks\":[{\"type\":\"link\",\"attrs\":{\"href\":\"https:\u002F\u002Fstart.spring.io\u002F\",\"target\":\"_blank\",\"rel\":\"noopener noreferrer nofollow\",\"class\":null,\"title\":null}}],\"text\":\"Spring initializer\"},{\"type\":\"text\",\"text\":\" for creating a Spring Boot project. Here is my sample project.\"}]},{\"type\":\"image\",\"attrs\":{\"src\":\"https:\u002F\u002Fapi.csbyte.com\u002Fuploads\u002Feditor\u002Ff4fb088d-1018-4d2b-ae6c-cdd5d0fd60ae_spring-Initializr.png\",\"alt\":null,\"title\":null,\"width\":null,\"height\":null}},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"The structure of the library project is similar to an application project; we don't have the main class. So, delete the main class. We also need to delete the main test class.\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"If you are using a multi-project setup, please include the project inside \"},{\"type\":\"text\",\"marks\":[{\"type\":\"code\"}],\"text\":\"settings.gradle\"},{\"type\":\"text\",\"text\":\" \"}]},{\"type\":\"codeBlock\",\"attrs\":{\"language\":\"bash\"},\"content\":[{\"type\":\"text\",\"text\":\"include 'csbyte-service'\"}]},{\"type\":\"heading\",\"attrs\":{\"textAlign\":null,\"level\":2},\"content\":[{\"type\":\"text\",\"text\":\"Setting build.gradle\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"Now, try to build your project with Gradle\"}]},{\"type\":\"codeBlock\",\"attrs\":{\"language\":\"bash\"},\"content\":[{\"type\":\"text\",\"text\":\" .\u002Fgradlew build\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"You might get the following error:\"}]},{\"type\":\"codeBlock\",\"attrs\":{\"language\":\"bash\"},\"content\":[{\"type\":\"text\",\"text\":\" Task :csbyte-service:bootJar FAILED\\n\\nFAILURE: Build failed with an exception.\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"This is due to the application trying to create the fat JAR file with the main class missing.\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"Let's replace the \"},{\"type\":\"text\",\"marks\":[{\"type\":\"code\"}],\"text\":\"org.springframework.boot\"},{\"type\":\"text\",\"text\":\" plugin with Spring’s explicit Bill of Materials (BOM) setup.\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"Remove the \"},{\"type\":\"text\",\"marks\":[{\"type\":\"code\"}],\"text\":\"org.springframework.boot\"},{\"type\":\"text\",\"text\":\" from \"},{\"type\":\"text\",\"marks\":[{\"type\":\"code\"}],\"text\":\"plugin{} \"},{\"type\":\"text\",\"text\":\"section.\"}]},{\"type\":\"codeBlock\",\"attrs\":{\"language\":\"bash\"},\"content\":[{\"type\":\"text\",\"text\":\"plugins {\\n\\tid 'java'\\n\\tid 'org.springframework.boot' version '3.5.14' \u002F\u002F remove it\\n\\tid 'io.spring.dependency-management' version '1.1.7'\\n}\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"Add the following configuration\"}]},{\"type\":\"codeBlock\",\"attrs\":{\"language\":\"bash\"},\"content\":[{\"type\":\"text\",\"text\":\"ext {\\n\\tspringBootVersion = '3.5.14'\\n}\\n\\ndependencies {\\n\\timplementation platform(\\\"org.springframework.boot:spring-boot-dependencies:${springBootVersion}\\\")\\n\\t\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"Make sure to use your own Spring Boot version.\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"Now, reload and sync the dependencies.\"}]},{\"type\":\"heading\",\"attrs\":{\"textAlign\":null,\"level\":3},\"content\":[{\"type\":\"text\",\"text\":\"Build the library\"}]},{\"type\":\"codeBlock\",\"attrs\":{\"language\":\"bash\"},\"content\":[{\"type\":\"text\",\"text\":\".\u002Fgradlew build\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"Output:\"}]},{\"type\":\"codeBlock\",\"attrs\":{\"language\":\"bash\"},\"content\":[{\"type\":\"text\",\"text\":\"BUILD SUCCESSFUL in 3s\\n36 actionable tasks: 2 executed, 34 up-to-date\"}]},{\"type\":\"heading\",\"attrs\":{\"textAlign\":null,\"level\":2},\"content\":[{\"type\":\"text\",\"text\":\"Importing the Library\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"Let's implement the library created in our applications. We can do it inside the \"},{\"type\":\"text\",\"marks\":[{\"type\":\"code\"}],\"text\":\"build.gradle\"},{\"type\":\"text\",\"text\":\" file's dependencies section as below.\"}]},{\"type\":\"codeBlock\",\"attrs\":{\"language\":\"bash\"},\"content\":[{\"type\":\"text\",\"text\":\"dependencies {\\n\\timplementation project(':csbyte-service')\\n    ------\\n}\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"type\":\"text\",\"text\":\"In this way, we can build the library which are common to application development so that they will be utilized in the application. This way, we can create a clean, maintainable, and enterprise-ready codebase structure.\"}]}]}","https:\u002F\u002Fapi.csbyte.com\u002Fuploads\u002Feditor\u002Ff4fb088d-1018-4d2b-ae6c-cdd5d0fd60ae_spring-Initializr.png",[11,12,13,14,15,16,17],"programming","coding","spring-boot-4","java","spring","spring-boot","spring-framework-7",[19,20],"Spring Framework","Spring Boot",[15,16],"2026-06-12T15:55:20.994Z",[24,31,37,43,49,54,60,66,72],{"alias":25,"title":26,"description":27,"thumbnail":28,"createdAt":29,"tutorialAlias":30,"lessonAlias":30},"multi-build-project-gradle-spring-boot","Setting up a multi-project build in Gradle for Spring Boot","How to set up a multi-project build in Gradle for Spring Boot","https:\u002F\u002Fapi.csbyte.com\u002Fuploads\u002Feditor\u002Fd43933e4-a7a3-404b-a300-8f02db98f549_multi-build-project.png","2026-06-12T04:15:23.045Z",null,{"alias":32,"title":33,"description":34,"thumbnail":35,"createdAt":36,"tutorialAlias":30,"lessonAlias":30},"java-version-mismatch-gradle","Java Version Mismatch for Gradle Build","How to Fix Gradle Error: Dependency requires at least JVM runtime version 17. This build uses a Java 8 JVM","\u002Fuploads\u002Fthumbnails\u002Fa4c6c910-5623-4db9-93f5-a515135adb99_gradle_version_mismatc.jpeg","2026-06-09T12:15:21.729Z",{"alias":38,"title":39,"description":40,"thumbnail":41,"createdAt":42,"tutorialAlias":30,"lessonAlias":30},"constructor-confusion-in-spring","Constructor Confusion in Spring Framework","Constructor Confusion and how to handle it in Spring Framework","\u002Fuploads\u002Fthumbnails\u002Fd0f09fc0-e1f9-49d1-bf9a-7d1c41050196_di_confusio.jpeg","2026-05-21T14:13:31.437Z",{"alias":44,"title":45,"description":46,"thumbnail":47,"createdAt":48,"tutorialAlias":30,"lessonAlias":30},"dependency-pull-lookup-spring","Dependency Pull and Contextualized Dependency Lookup in Spring Framework","Dependency Pull and Contextualized Dependency Lookup IoC Types in Spring Framework","\u002Fuploads\u002Fthumbnails\u002Fd1132443-313b-4dce-b713-55f356ef6051_depndency_pull.png","2026-05-20T15:26:06.494Z",{"alias":50,"title":51,"description":51,"thumbnail":52,"createdAt":53,"tutorialAlias":30,"lessonAlias":30},"types-of-dependency-injection-spring","Types of Dependency Injection in Spring Framework","\u002Fuploads\u002Fthumbnails\u002Fafb32399-6dda-41c4-b07c-7decb8257bbb_di_constructor_sette.jpeg","2026-05-19T17:01:51.972Z",{"alias":55,"title":56,"description":57,"thumbnail":58,"createdAt":59,"tutorialAlias":30,"lessonAlias":30},"spring-framework-project-for-gradle-with-intellij-idea","How to create a clean Spring Framework project for Gradle with IntelliJ IDEA","Create a clean Spring Framework project for Gradle with IntelliJ IDEA","https:\u002F\u002Fapi.csbyte.com\u002Fuploads\u002Feditor\u002F0e4abad5-17e2-4311-8cf0-7d8f67af975a_spring-framework.png","2026-05-19T10:28:20.866Z",{"alias":61,"title":62,"description":63,"thumbnail":64,"createdAt":65,"tutorialAlias":30,"lessonAlias":30},"spring-dependency-injection-and-inversion-control","Dependency Injection (DI) and Inversion of Control (IoC) in Spring","Mastering Dependency Injection (DI) and Inversion of Control (IoC) in Spring: A Practical Guide for Building a Notification System","\u002Fuploads\u002Fthumbnails\u002F53c64b94-f188-40b4-9ae9-ad97612d688b_spring_d.jpeg","2026-05-19T05:31:45.138Z",{"alias":67,"title":68,"description":69,"thumbnail":70,"createdAt":71,"tutorialAlias":30,"lessonAlias":30},"setting-nginx-ssl-for-spring-boot-application","Setup Nginx and SSL for Spring Boot Application","Setting Nginx as a reverse proxy in our Spring Boot application","\u002Fuploads\u002Fthumbnails\u002F5433c987-9e86-4d90-9cce-a831d1598ba4_spring-boot-nginx.png","2026-05-04T05:36:23.075Z",{"alias":73,"title":74,"description":75,"thumbnail":76,"createdAt":77,"tutorialAlias":30,"lessonAlias":30},"deploy-spring-boot-application-with-docker","Deploy Spring Boot Application with Docker on Ubuntu Server","The ultimate guide to deploying our Spring Boot application with Docker on an Ubuntu server","https:\u002F\u002Fapi.csbyte.com\u002Fuploads\u002Feditor\u002F55a11844-d1e9-4e83-80e5-c6bb6df7d58b_intellij-idea-build.png","2026-05-03T05:58:55.642Z"]