Skip to content

Commit

Permalink
feat: use a simplified database connection (#232)
Browse files Browse the repository at this point in the history
This changes the database connection without using the Spring GCP dependencies.

Related to #230
  • Loading branch information
SudharakaP authored Sep 9, 2020
1 parent e35439d commit 53dd27e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 28 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
files: '${{ github.workspace }}/app.yaml'
env:
env_variables.DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
env_variables.INSTANCE_CONNECTION_NAME: ${{ secrets.INSTANCE_CONNECTION_NAME }}
env_variables.GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
env_variables.GCP_REGION: ${{ secrets.GCP_REGION }}
env_variables.SQL_INSTANCE_ID: ${{ secrets.SQL_INSTANCE_ID }}
Expand Down
1 change: 0 additions & 1 deletion app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ manual_scaling:
instances: 1
env_variables:
DATABASE_NAME:
INSTANCE_CONNECTION_NAME:
GCP_PROJECT_ID:
GCP_REGION:
SQL_INSTANCE_ID:
Expand Down
13 changes: 4 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<junit.utReportFolder>${project.testresult.directory}/test</junit.utReportFolder>
<junit.itReportFolder>${project.testresult.directory}/integrationTest</junit.itReportFolder>
<!-- jhipster-needle-maven-property -->
<mysql-socket-factory.version>1.0.16</mysql-socket-factory.version>
</properties>

<dependencyManagement>
Expand All @@ -97,13 +98,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>1.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- jhipster-needle-maven-add-dependency-management -->
</dependencies>
</dependencyManagement>
Expand Down Expand Up @@ -1096,8 +1090,9 @@
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>${mysql-socket-factory.version}</version>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;

Expand Down
16 changes: 3 additions & 13 deletions src/main/resources/config/application-gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@
# ===================================================================

spring:
cloud:
gcp:
sql:
enabled: true
database-name: ${DATABASE_NAME}
instance-connection-name: ${INSTANCE_CONNECTION_NAME}
datasource:
hikari:
data-source-properties:
socketFactory: com.google.cloud.sql.mysql.SocketFactory
cloudSqlInstance: ${GCP_PROJECT_ID}:${GCP_REGION}:${SQL_INSTANCE_ID}
jdbcUrl: jdbc:mysql://google/${DATABASE_NAME}
username: ${DATABASE_USERNAME}
password: ${DATABASE_PASSWORD}
url: jdbc:mysql://google/${DATABASE_NAME}?cloudSqlInstance=${GCP_PROJECT_ID}:${GCP_REGION}:${SQL_INSTANCE_ID}&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false
username: ${DATABASE_USERNAME}
password: ${DATABASE_PASSWORD}
mail:
host: ${MAIL_HOST}
port: ${MAIL_PORT}
Expand Down

0 comments on commit 53dd27e

Please sign in to comment.