Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test | Version And Config Update | SIS-91 #46

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.graduation-project</groupId>
<artifactId>student-information-system-be</artifactId>
<version>v1.0.0</version>
<version>v1.1.0</version>
<packaging>war</packaging>
<name>Student Information System</name>
<description>Student Information System for Higher Education</description>
Expand Down Expand Up @@ -172,7 +172,8 @@
<appName>sis-be</appName>
<jdkVersion>17.0.1</jdkVersion>
<processTypes>
<web>java -Dserver.port=$PORT $JAVA_OPTS -jar target/*.war</web>
<web>java -Dserver.port=$PORT -Dspring.profiles.active=mysql-live $JAVA_OPTS -jar target/*.war
</web>
</processTypes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public class SisHikariConfigProfileDto {

private final String username;
private final String password;
private final String url;
private final String maxPoolSize;
private final String tnsJdbcUrl;
private final String driverClassName;
private final String connectionTimeout;
private final String maxLifetime;
private final String driverClassName;

public static void checkProfileVariables(final SisHikariConfigProfileDto hikariConfigProfile) {
if (!StringUtils.hasText(hikariConfigProfile.getUsername())) {
Expand All @@ -29,8 +29,8 @@ public static void checkProfileVariables(final SisHikariConfigProfileDto hikariC
log.error(message);
throw new NullPointerException(message);
}
if (!StringUtils.hasText(hikariConfigProfile.getTnsJdbcUrl())) {
final String message = "Hikari tnsJdbcUrl Cannot be Empty!";
if (!StringUtils.hasText(hikariConfigProfile.getUrl())) {
final String message = "Hikari url Cannot be Empty!";
log.error(message);
throw new NullPointerException(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public static HikariConfig getHikariConfigBaseValues(final SisHikariConfigProfil

hikariConfig.setUsername(hikariConfigProfileDto.getUsername());
hikariConfig.setPassword(hikariConfigProfileDto.getPassword());
hikariConfig.setJdbcUrl(hikariConfigProfileDto.getTnsJdbcUrl());
hikariConfig.setDriverClassName(hikariConfigProfileDto.getDriverClassName());
hikariConfig.setAutoCommit(true);
hikariConfig.setJdbcUrl(hikariConfigProfileDto.getUrl());
hikariConfig.setMaximumPoolSize(Integer.parseInt(hikariConfigProfileDto.getMaxPoolSize()));
hikariConfig.setConnectionTimeout(Long.parseLong(hikariConfigProfileDto.getConnectionTimeout()));
hikariConfig.setMaxLifetime(Long.parseLong(hikariConfigProfileDto.getMaxLifetime()));
hikariConfig.setMaximumPoolSize(Integer.parseInt(hikariConfigProfileDto.getMaxPoolSize()));
hikariConfig.setDriverClassName(hikariConfigProfileDto.getDriverClassName());
hikariConfig.setAutoCommit(true);

return hikariConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import javax.sql.DataSource;

@Slf4j
@Profile({DbProfile.MYSQL, DbProfile.DEFAULT})
@Profile({DbProfile.MYSQL, DbProfile.MYSQL_LIVE, DbProfile.DEFAULT})
@Configuration
@RequiredArgsConstructor
public class SisMysqlHikariConfiguration {
Expand Down Expand Up @@ -42,13 +42,13 @@ Sql2o sql2oMysql(DataSource hikariMysql) {

private static SisHikariConfigProfileDto getHikariConfigProfile(final Environment environment) {
return SisHikariConfigProfileDto.builder()
.username(environment.getProperty("hikariMysql.username"))
.password(environment.getProperty("hikariMysql.password"))
.maxPoolSize(environment.getProperty("hikariMysql.maxPoolSize"))
.tnsJdbcUrl(environment.getProperty("hikariMysql.tns.jdbc.url"))
.driverClassName("com.mysql.cj.jdbc.Driver")
.connectionTimeout(environment.getProperty("hikari.connectionTimeout"))
.maxLifetime(environment.getProperty("hikari.maxLifetime")).build();
.username(environment.getProperty("hikari-mysql.username"))
.password(environment.getProperty("hikari-mysql.password"))
.url(environment.getProperty("hikari-mysql.url"))
.maxPoolSize(environment.getProperty("hikari-mysql.max-pool-size"))
.connectionTimeout(environment.getProperty("hikari-mysql.connection-timeout"))
.maxLifetime(environment.getProperty("hikari-mysql.max-lifetime"))
.driverClassName("com.mysql.cj.jdbc.Driver").build();
}

private static HikariConfig getHikariConfig(final SisHikariConfigProfileDto hikariConfigProfileDto) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.graduationproject.studentinformationsystem.common.config;

import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
Expand All @@ -10,7 +14,9 @@
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Component
@Configuration
@ConfigurationProperties("sis")
public class SisSwaggerConfiguration {

public static final String FACULTY_API_TAG = "Faculty Controller";
Expand Down Expand Up @@ -41,10 +47,18 @@ public Docket api() {
);
}

@Setter
@Value("title")
private String title;

@Setter
@Value("version")
private String version;

private ApiInfo apiEndPointsInfo() {
return new ApiInfoBuilder()
.title("Student Information System API")
.version("v1.0.0")
.title(title)
.version(version)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ private DbProfile() {

public static final String DEFAULT = "default";
public static final String MYSQL = "mysql";
public static final String MYSQL_LIVE = "mysql-live";
}
}
8 changes: 0 additions & 8 deletions src/main/resources/application.properties

This file was deleted.

34 changes: 34 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
sis:
title: Student Information System API
version: v1.1.0

---
spring:
config:
activate:
on-profile: mysql

server:
port: 8585

hikari-mysql:
username: sis
password: sispass
url: jdbc:mysql://localhost:3306/sis
max-pool-size: 5
connection-timeout: 180000
max-lifetime: 170000

---
spring:
config:
activate:
on-profile: mysql-live

hikari-mysql:
username: e2ikxn8dldp8frup
password: x6fvgr8gj62ba8b9
url: jdbc:mysql://r6ze0q02l4me77k3.chr7pe7iynqr.eu-west-1.rds.amazonaws.com:3306/lvmp8pcqa129kizx
max-pool-size: 5
connection-timeout: 180000
max-lifetime: 170000
2 changes: 1 addition & 1 deletion src/main/resources/banner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
${AnsiColor.BRIGHT_YELLOW} / _____/${AnsiColor.BLUE} / /${AnsiColor.DEFAULT} / _____/
${AnsiColor.BRIGHT_YELLOW} \___ \ ${AnsiColor.BLUE} / /${AnsiColor.DEFAULT} \___ \
${AnsiColor.BRIGHT_YELLOW} ____/ / ${AnsiColor.BLUE}/ / ${AnsiColor.DEFAULT} ____/ /
${AnsiColor.BRIGHT_YELLOW} /_______/ ${AnsiColor.BLUE}/__/ ${AnsiColor.DEFAULT}/_______/${AnsiColor.BRIGHT_WHITE}〔v1.0.0
${AnsiColor.BRIGHT_YELLOW} /_______/ ${AnsiColor.BLUE}/__/ ${AnsiColor.DEFAULT}/_______/${AnsiColor.BRIGHT_WHITE}〔${sis.version}
:: Student Information System ::${AnsiColor.DEFAULT}