Update databse to be run on Azure Cloud

Signed-off-by: Martin Zatovic <m.zatovic1@gmail.com>
This commit is contained in:
Martin Zatovic 2024-05-24 00:56:26 +02:00
parent 6386ca5a5c
commit cee69dfdca
5 changed files with 60 additions and 39 deletions

View file

@ -7,6 +7,10 @@ plugins {
id "io.spring.nohttp" version "0.0.11"
}
plugins {
id "com.microsoft.azure.azurewebapp" version "1.10.0"
}
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'io.spring.javaformat'
@ -80,3 +84,16 @@ checkFormatAotTest.enabled = false
formatAot.enabled = false
formatAotTest.enabled = false
azurewebapp {
subscription = 'c68c793f-ad34-4871-bb6d-88e912e3afc7'
resourceGroup = 'pa200_group'
appName = 'Petclinic-SpringApp'
pricingTier = 'B1'
region = 'westeurope'
runtime {
os = 'Linux'
webContainer = 'Tomcat 9.0'
javaVersion = 'Java 17'
}
}

34
pom.xml
View file

@ -139,6 +139,34 @@
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>5.12.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.azure/azure-spring-boot-starter -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-spring-boot-starter</artifactId>
<version>2.3.5</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.4.0.jre8</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
@ -220,7 +248,7 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<!-- Spring Boot Actuator displays build-related information
<!-- Spring Boot Actuator displays build-related information
if a META-INF/build-info.properties file is present -->
<goals>
<goal>build-info</goal>
@ -378,7 +406,7 @@
<build>
<pluginManagement>
<plugins>
<!-- This plugin's configuration is used to store Eclipse m2e settings
<!-- This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
@ -436,4 +464,4 @@
</profile>
</profiles>
</project>
</project>

View file

@ -1,7 +0,0 @@
# database init, supports mysql too
database=mysql
spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/petclinic}
spring.datasource.username=${MYSQL_USER:petclinic}
spring.datasource.password=${MYSQL_PASS:petclinic}
# SQL is written to be idempotent so this is safe
spring.sql.init.mode=always

View file

@ -1,6 +0,0 @@
database=postgres
spring.datasource.url=${POSTGRES_URL:jdbc:postgresql://localhost/petclinic}
spring.datasource.username=${POSTGRES_USER:petclinic}
spring.datasource.password=${POSTGRES_PASS:petclinic}
# SQL is written to be idempotent so this is safe
spring.sql.init.mode=always

View file

@ -1,25 +1,14 @@
# database init, supports mysql too
database=h2
logging.level.org.hibernate.SQL=DEBUG
spring.datasource.url=jdbc:sqlserver://pa200-db-server.database.windows.net:1433;database=pa200_application_db;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
spring.datasource.username=manager
spring.datasource.password=KDVYyIyKq8CRQ
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2016Dialect
spring.jpa.hibernate.ddl-auto=create-drop
spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql
spring.sql.init.data-locations=classpath*:db/${database}/data.sql
spring.sql.init.data-locations=classpath*:db/data.sql
spring.jpa.defer-datasource-initialization= true
# Web
spring.thymeleaf.mode=HTML
# JPA
spring.jpa.hibernate.ddl-auto=none
spring.jpa.open-in-view=true
# Internationalization
spring.messages.basename=messages/messages
# Actuator
management.endpoints.web.exposure.include=*
# Logging
logging.level.org.springframework=INFO
# logging.level.org.springframework.web=DEBUG
# logging.level.org.springframework.context.annotation=TRACE
# Maximum time static resources should be cached
spring.web.resources.cache.cachecontrol.max-age=12h
spring.sql.init.mode=always