├── .gitignore
├── README.md
├── application
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── purnima
│ └── jain
│ └── customer
│ └── CustomerApplication.java
├── controller
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── purnima
│ └── jain
│ └── customer
│ └── controller
│ └── CustomerController.java
├── domain
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── purnima
│ └── jain
│ └── customer
│ └── domain
│ ├── aggregate
│ └── Customer.java
│ ├── repository
│ └── CustomerRepository.java
│ └── service
│ └── CustomerService.java
├── pom.xml
├── repository
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── purnima
│ └── jain
│ └── customer
│ └── repository
│ └── implementation
│ └── CustomerRepositoryImpl.java
└── service
├── pom.xml
└── src
└── main
└── java
└── com
└── purnima
└── jain
└── customer
└── service
└── implementation
└── CustomerServiceImpl.java
/.gitignore:
--------------------------------------------------------------------------------
1 | ##############################
2 | ## Java
3 | ##############################
4 | .mtj.tmp/
5 | *.class
6 | *.jar
7 | *.war
8 | *.ear
9 | *.nar
10 | hs_err_pid*
11 |
12 | ##############################
13 | ## Maven
14 | ##############################
15 | target/
16 | pom.xml.tag
17 | pom.xml.releaseBackup
18 | pom.xml.versionsBackup
19 | pom.xml.next
20 | pom.xml.bak
21 | release.properties
22 | dependency-reduced-pom.xml
23 | buildNumber.properties
24 | .mvn/timing.properties
25 | .mvn/wrapper/maven-wrapper.jar
26 |
27 | ##############################
28 | ## Gradle
29 | ##############################
30 | bin/
31 | build/
32 | .gradle
33 | .gradletasknamecache
34 | gradle-app.setting
35 | !gradle-wrapper.jar
36 |
37 | ##############################
38 | ## IntelliJ
39 | ##############################
40 | out/
41 | .idea/
42 | .idea_modules/
43 | *.iml
44 | *.ipr
45 | *.iws
46 |
47 | ##############################
48 | ## Eclipse
49 | ##############################
50 | .settings/
51 | bin/
52 | tmp/
53 | .metadata
54 | .classpath
55 | .project
56 | *.tmp
57 | *.bak
58 | *.swp
59 | *~.nib
60 | local.properties
61 | .loadpath
62 | .factorypath
63 |
64 | ##############################
65 | ## NetBeans
66 | ##############################
67 | nbproject/private/
68 | build/
69 | nbbuild/
70 | dist/
71 | nbdist/
72 | nbactions.xml
73 | nb-configuration.xml
74 |
75 | ##############################
76 | ## Visual Studio Code
77 | ##############################
78 | .vscode/
79 |
80 | ##############################
81 | ## OS X
82 | ##############################
83 | .DS_Store
84 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Spring Boot Multi-Module Maven Project with DDD
2 | Spring Boot & Multi-Module Maven Project following DDD Methodology.
3 |
4 | Ref: https://dzone.com/articles/ddd-spring-boot-multi-module-maven-project
5 |
6 |
--------------------------------------------------------------------------------
/application/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 |
7 | com.purnima.jain
8 | spring-boot-multi-module
9 | 0.0.1-SNAPSHOT
10 |
11 |
12 | application
13 |
14 |
15 |
16 | com.purnima.jain
17 | controller
18 | ${project.version}
19 |
20 |
21 | com.purnima.jain
22 | service
23 | ${project.version}
24 |
25 |
26 | com.purnima.jain
27 | repository
28 | ${project.version}
29 |
30 |
31 |
--------------------------------------------------------------------------------
/application/src/main/java/com/purnima/jain/customer/CustomerApplication.java:
--------------------------------------------------------------------------------
1 | package com.purnima.jain.customer;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 |
8 | @SpringBootApplication
9 | public class CustomerApplication {
10 |
11 | private static final Logger logger = LoggerFactory.getLogger(CustomerApplication.class);
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(CustomerApplication.class, args);
15 | logger.info("CustomerApplication Started........");
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/controller/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 |
7 | com.purnima.jain
8 | spring-boot-multi-module
9 | 0.0.1-SNAPSHOT
10 |
11 |
12 | controller
13 |
14 |
15 |
16 | com.purnima.jain
17 | domain
18 | ${project.version}
19 |
20 |
21 |
--------------------------------------------------------------------------------
/controller/src/main/java/com/purnima/jain/customer/controller/CustomerController.java:
--------------------------------------------------------------------------------
1 | package com.purnima.jain.customer.controller;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.PathVariable;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | import com.purnima.jain.customer.domain.aggregate.Customer;
11 | import com.purnima.jain.customer.domain.service.CustomerService;
12 |
13 | @RestController
14 | public class CustomerController {
15 |
16 | private static final Logger logger = LoggerFactory.getLogger(CustomerController.class);
17 |
18 | @Autowired
19 | private CustomerService customerService;
20 |
21 | @GetMapping("customer/{customerId}")
22 | public Customer getCustomer(@PathVariable Integer customerId) {
23 | logger.info("Inside CustomerController........");
24 | return customerService.getCustomerById(customerId);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/domain/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 |
7 | com.purnima.jain
8 | spring-boot-multi-module
9 | 0.0.1-SNAPSHOT
10 |
11 |
12 | domain
13 |
14 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/purnima/jain/customer/domain/aggregate/Customer.java:
--------------------------------------------------------------------------------
1 | package com.purnima.jain.customer.domain.aggregate;
2 |
3 | public class Customer {
4 |
5 | private Integer customerId;
6 | private String customerName;
7 |
8 | public Customer(Integer customerId, String customerName) {
9 | super();
10 | this.customerId = customerId;
11 | this.customerName = customerName;
12 | }
13 |
14 | public Integer getCustomerId() {
15 | return customerId;
16 | }
17 |
18 | public String getCustomerName() {
19 | return customerName;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/purnima/jain/customer/domain/repository/CustomerRepository.java:
--------------------------------------------------------------------------------
1 | package com.purnima.jain.customer.domain.repository;
2 |
3 | import com.purnima.jain.customer.domain.aggregate.Customer;
4 |
5 | public interface CustomerRepository {
6 |
7 | public Customer getCustomerById(Integer customerId);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/purnima/jain/customer/domain/service/CustomerService.java:
--------------------------------------------------------------------------------
1 | package com.purnima.jain.customer.domain.service;
2 |
3 | import com.purnima.jain.customer.domain.aggregate.Customer;
4 |
5 | public interface CustomerService {
6 |
7 | public Customer getCustomerById(Integer customerId);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 |
7 | org.springframework.boot
8 | spring-boot-starter-parent
9 | 2.2.6.RELEASE
10 |
11 |
12 | com.purnima.jain
13 | spring-boot-multi-module
14 | 0.0.1-SNAPSHOT
15 |
16 | pom
17 |
18 |
19 | UTF-8
20 | 11
21 |
22 |
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-web
27 |
28 |
29 |
30 |
31 | application
32 | controller
33 | domain
34 | service
35 | repository
36 |
37 |
--------------------------------------------------------------------------------
/repository/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 |
7 | com.purnima.jain
8 | spring-boot-multi-module
9 | 0.0.1-SNAPSHOT
10 |
11 |
12 | repository
13 |
14 |
15 |
16 | com.purnima.jain
17 | domain
18 | ${project.version}
19 |
20 |
21 |
--------------------------------------------------------------------------------
/repository/src/main/java/com/purnima/jain/customer/repository/implementation/CustomerRepositoryImpl.java:
--------------------------------------------------------------------------------
1 | package com.purnima.jain.customer.repository.implementation;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import com.purnima.jain.customer.domain.aggregate.Customer;
8 | import com.purnima.jain.customer.domain.repository.CustomerRepository;
9 |
10 | @Repository
11 | public class CustomerRepositoryImpl implements CustomerRepository {
12 |
13 | private static final Logger logger = LoggerFactory.getLogger(CustomerRepositoryImpl.class);
14 |
15 | @Override
16 | public Customer getCustomerById(Integer customerId) {
17 | logger.info("Inside CustomerRepositoryImpl........");
18 | // Replace this code to retrieve from database
19 | Customer customer = new Customer(100, "A New Customer");
20 | return customer;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/service/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 |
7 | com.purnima.jain
8 | spring-boot-multi-module
9 | 0.0.1-SNAPSHOT
10 |
11 |
12 | service
13 |
14 |
15 |
16 | com.purnima.jain
17 | domain
18 | ${project.version}
19 |
20 |
21 |
--------------------------------------------------------------------------------
/service/src/main/java/com/purnima/jain/customer/service/implementation/CustomerServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.purnima.jain.customer.service.implementation;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import com.purnima.jain.customer.domain.aggregate.Customer;
9 | import com.purnima.jain.customer.domain.repository.CustomerRepository;
10 | import com.purnima.jain.customer.domain.service.CustomerService;
11 |
12 | @Service
13 | public class CustomerServiceImpl implements CustomerService {
14 |
15 | private static final Logger logger = LoggerFactory.getLogger(CustomerServiceImpl.class);
16 |
17 | @Autowired
18 | private CustomerRepository customerRepository;
19 |
20 | @Override
21 | public Customer getCustomerById(Integer customerId) {
22 | logger.info("Inside CustomerServiceImpl........");
23 | Customer customer = customerRepository.getCustomerById(customerId);
24 | return customer;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------