3

I have Spring boot Rest api , which works fine

@RequestMapping("/api/get")
public PomData getPomData( ) throws IOException {

    PomData pd=new PomData();
    pd.setName("name");
    pd.setVersion("version");

    return pd;

}

I want to call this

getPomData() (@RequestMapping 'api/get')

via URL, From Another project.

I've added this to that another project's POM file

<dependency>
<groupId>RestApi</groupId>
<artifactId>RestApi</artifactId>
<version>1.0.0</version>
<systemPath>${project.basedir}/src/main/resources/RestApi.jar</systemPath>
</dependency>

ANd i'm trying to send request to url using ajax like this

$.ajax({url: "/api/get",success: function(result){
      alert();
    }});

but 404 PAGE NOT FOUND what To do?

  • Are you trying to develop some kind of microservice based architecture? Then, you should consider launching the two services separately, and not include one into another as a dependency. – Aritz Mar 25 '17 at 10:27
  • thank you for answer. i'm making some own libraries. exactly, that method must return Project's POM.xml info From which I'll call it. – Tsotne Maisuradze Mar 25 '17 at 10:41
  • 2
    Your problem probably is spring-boot isn't searching in the right place. A `@SpringBootApplication` searches by default in the package its declared in and its sub-packages. So if your `@SpringBootApplication` is in `com.tsotne.myapp` but your api is in `com.tsotne.myapi`, it won't find the `@RequestMapping` because it's not in `com.tsotne.myapp`. If you add `@ComponentScan(basePackages = "com.tsotne.myapi")`, it should find it. – mnewton Mar 26 '17 at 03:37
  • thank you mnewton, it works. – Tsotne Maisuradze Mar 26 '17 at 06:51

0 Answers0