Skip to content

Latest commit

 

History

History
81 lines (68 loc) · 2.78 KB

File metadata and controls

81 lines (68 loc) · 2.78 KB

Spring cloud microservices

This is a monorepo for a microservice demo project to use RabbitMQ as message broker

Preparation

  1. In order to setup the monorepo structure, we first have to create a maven project from scratch using this command:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

Replace the groupId and artifactId for the one desired.

  1. Delete the src folder since the root folder won't be having code but instead modules.

  2. Update POM dependencies, managed dependencies and plugins sections to look like this:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.ms</groupId>
  <artifactId>spring-cloud-ms</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <modules>
    <module>users</module>
  </modules>

  <name>spring-cloud-ms</name>
  <!-- FIXME change it to the project's website -->
  <url>https://www.spring-cloud-ms.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>18</maven.compiler.source>
    <maven.compiler.target>18</maven.compiler.target>
    <spring.boot.maven.plugin.version>2.6.6</spring.boot.maven.plugin.version>
    <spring.boot.dependencies.version>2.6.6</spring.boot.dependencies.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring.boot.maven.plugin.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <!--  All submodules will share everything located under dependencies -->
  <dependencies>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.24</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${spring.boot.maven.plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>