3


All I'm new on Spring boot and have a question. Currently I'm working with the spring boot multi module project. I have 3 spring boot project.
like A,B,C, each have rest-controller like below:-
--------------------Project-A----------------------------------

@RequestMapping(value = "/demoa")
public String demoa() {
    return "demoa";
}

--------------------Project-B----------------------------------

@RequestMapping(value = "/demob")
public String demob() {
    return "demob";
}

--------------------Project-C----------------------------------

@RequestMapping(value = "/democ")
public String democ() {
    return "democ";
}

I add the both (B, C) project as a mavend dependency in Project(A) and compiled all

<dependency>
    <groupId>com.b</groupId>
    <artifactId>demob</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>com.c</groupId>
    <artifactId>democ</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

after that i run my project like "mvn Spring-boot run" it run on 8080. When i call the "Rest /demoa" it give me the response while when i try to call other rest it show these error below:

{
    "timestamp": "2018-04-25T14:47:56.816+0000",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/demob"
}

My Question is how I get the response of both 2 api while running the project"A"

Yogesh_D
  • 17,656
  • 10
  • 41
  • 55
Nabeel Ahmed
  • 258
  • 1
  • 7
  • 23

2 Answers2

1

You need to make sure that your controllers in Project A and Project B are scanned and autoconfigured. What you need to do is to use the @ComponentScan annotation in your main class and give it packages on Components and Controllers in the Project A and Project B

Yogesh_D
  • 17,656
  • 10
  • 41
  • 55
-2

For /demob and /democ. You need to run the corresponding projects or:

You can:

  • deploy all projects in your single tomcat server.
  • Deploy a load balancer from your hosting provider, or you can use Nginx for doing that.
  • Have three tomcat servers.
  • Have single spring boot project but three Rest controllers.
Shanu Gupta
  • 3,699
  • 2
  • 19
  • 29