Technical Blog

Mono Repo.

Creating a mono repo.

Mono repo means one Git repository that contains multiple projects AND is designed to be developed, built, tested, and versioned together in a controlled way.

There should be one shared build system and dependency management.

Say there are projects like product service and app service and all inside a big project then there should one pom file in the parent repo and it will contain all the modules. All are individual projects. One project spring-monorepo and there git init and pom dependency file added manually. The using spring initializer artifact product-service and app-service is created using spring web dependencies. The zip file is extracted to the spring-monorepo project.

In the product-service/pom.xml file we need to replace groupId and artifactId.

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
</parent>

It should be.


<parent>
  <groupId>com.example</groupId>
  <artifactId>spring-monorepo</artifactId>
  <version>1.0.0</version>
</parent>

In the main pom file there the groupId is given as com.example and the module include the project name.



<modules>
    <module>product-service</module>
    <module>app-service</module>
</modules>

Reference project https://github.com/Suchismita-Deb/spring-monorepo

Build in submodule project.

There is a project and a lot of submodule and to run one project the other build should be ready. There is an order to build the project say first the platform-bom, core-parent, core-common and auth-service.

# Build in this exact order:
cd bv-core-platform-bom && mvn clean install -DskipTests && cd ..
cd bv-core-parent && mvn clean install -DskipTests && cd ..
cd bv-core-common && mvn clean install -DskipTests && cd ..
cd bv-auth-service && mvn clean install -DskipTests && cd ..

Teh question was like these are individual projects and the build of one project will impact the other one in what way as the project are repo. When the platform-bom is build it will create the dependencies in the .m2 repositories. The .m2 file is in the C User and the hp ~/.m2/repository/com/bit/velocity/

Java version.

Window version is different and the intellij version is different. In the project module we can set to java 21 and in the window path set to java 20 then maven will take the window path and the solution is to change the variable to 21.

In the program Files/Java/jdk20 install and put the java 21 file. Then in the env variable in the path remove all the jdk path and put the %JAVA_HOME%\bin and the value JAVA_HOME = C:\Program Files\Java\jdk-21.0.9 Remove any other jdk path in the variable as it will take the one and also any oracle java C:\Program Files\Common Files\Oracle\Java\javapath and it has the symlinks to the older java 20.

Window has 2 paths the system path and the local path. The CMD takes in the order of the system then user. In the CMD command where java should point to jdk 21 and java –version should be 21.