I tried to deploy with Google App Engine Deployment after I configured mysql on Google Cloud. On localhost it runs perfectly, but when I tried to run in the server it has some problems. I found a solution to lower my java version but I need java 11, is there any solution to deploy my app with java 11?
The error:
File upload done.
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: Frontend automatic scaling should NOT have the following parameter(s): [max_total_instances, min_total_instances] (or "version.env" should be set to "flex"
- '@type': type.googleapis.com/google.rpc.BadRequest
fieldViolations:
- description: 'Frontend automatic scaling should NOT have the following parameter(s):
[max_total_instances, min_total_instances] (or "version.env" should be set to
"flex"'
field: version.automatic_scaling
Failed to deploy '[2021-11-10 23:11:21] Maven build: backend. Project: buildtogether. Version: auto': Deployment failed with exit code: 1
Please make sure that you are using the latest version of the Google Cloud SDK.
Run ''gcloud components update'' to update the SDK. (See: https://cloud.google.com/sdk/gcloud/reference/components/update.)
My pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ubul_studio</groupId>
<artifactId>build_together</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>build_together</name>
<description>Backend for the Build Together mobile and webapp</description>
<properties>
<java.version>11</java.version>
</properties>
<!-- Add Spring Cloud GCP Dependency BOM -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>2.0.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>com.neovisionaries</groupId>
<artifactId>nv-i18n</artifactId>
<version>1.22</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<version>1</version>
<projectId>buildtogether</projectId>
</configuration>
</plugin>
</plugins>
</build>
</project>
My app.yaml:
runtime: java11
instance_class: F2
env_variables:
BUCKET_NAME: "example-gcs-bucket"
handlers:
- url: /stylesheets
static_dir: stylesheets
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
automatic_scaling:
min_num_instances: 1
max_num_instances: 8
my application.yml:
spring:
cloud:
gcp:
sql:
database-name: buildtogether
instance-connection-name: buildtogether:europe-central2:buildtogether
datasource:
password: buildtogether
username: root
url: jdbc:mysql://34.116.151.33:3306/buildtogether
profiles:
active: mysql
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL57InnoDBDialect
liquibase:
change-log: classpath:database/db.changelog-master.xml
default-schema: buildtogether
sql:
init:
mode: always
CodePudding user response:
See the documentation for app.yml. I believe that you should specify min_instances
and max_instances
, not min_num_instances
and max_num_instances
.
min_num_instances
and max_num_instances
are applicable to the python runtime.