Template repository Spring Boot and Google Compute Platform (GCP)
gcloud config list project
gcloud config set project <PROJECT_ID>
- Project: Maven Project
- Languaje: Java
- Spring Boot: 2.5.5
- Packaging: Ja
- Java: 11
- Dependencies: Spring Web, Lombok, Spring Data JPA, H2
Spring initializr configuration
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" ...>
...
<build>
<plugins>
...
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<version>1</version>
<projectId>GCLOUD_CONFIG</projectId>
</configuration>
</plugin>
...
</plugins>
</build>
</project>
mkdir -p src/main/appengine/
touch src/main/appengine/app.yam
// Add the controller.
@RestController
class HelloWorldController {
@GetMapping("/")
public String hello() {
return "hello world!";
}
.\mvnw.cmd -DskipTests spring-boot:run
Initialize the project to be able to run App Engine apps
gcloud app create --region southamerica-east1
Deploy the app
./mvnw -DskipTests package appengine:deploy
Open
gcloud app browse