REST API Spring Boot недоступен в GCP - PullRequest
1 голос
/ 26 марта 2019

Я развернул API Spring Boot Rest в Google Cloud Platform.Rest API отлично работает в моем локальном приложении, когда приложение запускается как загрузочное приложение Spring.Но тот же URL REST API не распознается при развертывании в GCP.

Структура проекта: Project structure

app.yaml:

runtime: java
env: flex
runtime_config:
  jdk: openjdk8

handlers:
  - url: /.*
    script: this field is required, but ignored

GreetingController.java

package com.designdreamers.rest.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.designdreamers.rest.vo.Greeting;

@RestController
public class GreetingController {

    private int idValue;

    @RequestMapping(value="/greet")
    public Greeting greeting(@RequestParam(value="content", defaultValue = "Hello World!!")String content){

        Greeting greeting=new Greeting();
        greeting.setId(idValue++);
        greeting.setContent(content);
        return greeting;
    }
}

Application.java

package com.designdreamers.rest.main;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;


@SpringBootApplication
@ComponentScan(basePackages = "com.designdreamers.rest.controller")
public class Application {

    public static void main(String args[]){
        SpringApplication.run(Application.class,args);
    }
}

Нижеответ REST API, который я получаю при запуске приложения как локального загрузочного приложения Spring.

URL: http://localhost:8080/greet

{"id":1,"content":"Hello World!!"}

Я развернул то же приложениев GCP и при нажатии URI API REST ниже приводится ошибка, которую мы получаем.

URI: http://helloworld -001.appspot.com / greet

Error: Not Found
The requested URL /greet was not found on this server.

Помощь в определении проблемы была бы очень полезна.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...