Skip to content

Commit

Permalink
Merge pull request #24 from softeerbootcamp4th/feature/#21-spring-boo…
Browse files Browse the repository at this point in the history
…t-mysql-connect

Feature/#21 spring boot mysql connect
  • Loading branch information
wjddn2165 authored Jul 31, 2024
2 parents 99478e6 + 01d5ff4 commit 054aee5
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 8 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,5 @@ jobs:
key: ${{ secrets.EC2_SECRET }}
script: |
cd /home/ubuntu/spring-boot
echo "SPRING_DATASOURCE_URL=${{ secrets.SPRING_DATASOURCE_URL }}" > .env
echo "SPRING_DATASOURCE_USERNAME=${{ secrets.SPRING_DATASOURCE_USERNAME }}" >> .env
echo "SPRING_DATASOURCE_PASSWORD=${{ secrets.SPRING_DATASOURCE_PASSWORD }}" >> .env
echo "SPRING_JPA_HIBERNATE_DDL_AUTO=update" >> .env
echo "SPRING_REDIS_HOST=redis" >> .env
echo "SPRING_REDIS_PORT=6379" >> .env
docker-compose pull
docker-compose up -d
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/Server/.gradle/
/Server/.idea/
/Server/build/
/Server/src/main/resources/application.properties
/.idea/
/Server/out/
18 changes: 17 additions & 1 deletion Server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,30 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'org.apache.commons:commons-dbcp2:2.9.0'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'software.amazon.awssdk:ssm'
implementation 'software.amazon.awssdk:auth'
implementation platform("io.awspring.cloud:spring-cloud-aws-dependencies:3.1.0")
implementation platform('com.amazonaws:aws-java-sdk-bom:1.12.529')
implementation 'io.awspring.cloud:spring-cloud-aws-starter-parameter-store'
implementation 'mysql:mysql-connector-java:8.0.33' // MySQL JDBC 드라이버 추가

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

runtimeOnly 'com.h2database:h2'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
}


tasks.named('test') {
useJUnitPlatform()
}

configurations {
all {
exclude group: 'commons-logging', module: 'commons-logging'
}
}
40 changes: 40 additions & 0 deletions Server/src/main/java/JGS/CasperEvent/global/config/AppConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package JGS.CasperEvent.global.config;

import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class AppConfig {

@Value("${SPRING_DATASOURCE_URL}")
private String datasourceUrl;

@Value("${SPRING_DATASOURCE_USERNAME}")
private String datasourceUsername;

@Value("${SPRING_DATASOURCE_PASSWORD}")
private String datasourcePassword;

@Value("${SPRING_JPA_HIBERNATE_DDL_AUTO}")
private String hibernateDdlAuto;

@Value("${SPRING_REDIS_HOST}")
private String redisHost;

@Value("${SPRING_REDIS_PORT}")
private String redisPort;

@Bean
public DataSource dataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setUrl(datasourceUrl);
dataSource.setUsername(datasourceUsername);
dataSource.setPassword(datasourcePassword);
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
return dataSource;
}
}
13 changes: 13 additions & 0 deletions Server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
spring:
jpa:
hibernate:
ddl-auto: update
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect

aws:
region: ap-northeast-2

spring.config.import: aws-parameterstore:/spring-app/

0 comments on commit 054aee5

Please sign in to comment.