Skip to content

Commit

Permalink
Merge pull request #4 from Dae-Hwa/BE/preparation/project-setup
Browse files Browse the repository at this point in the history
[Be]project setup
  • Loading branch information
Jiwon-JJW committed Apr 20, 2021
2 parents a72f475 + 9ebace6 commit b0dd692
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 2 deletions.
21 changes: 21 additions & 0 deletions be/sidedish-be/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,24 @@ dependencies {
test {
useJUnitPlatform()
}

ext.profile = (!project.hasProperty('profile') || !profile) ? 'dev' : profile

sourceSets {
main {
java {
}
resources {
srcDirs += ["src/main/resources-${profile}"]
}
}
}

task build_prod(type: GradleBuild) {
startParameter.setTaskNames(["build"])
startParameter.setProjectProperties(new HashMap() {
{
put("profile", "prod")
}
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.codesquad.sidedish.temp;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
@GetMapping("/hello")
public String hello() {
return "hello";
}
}
15 changes: 15 additions & 0 deletions be/sidedish-be/src/main/resources-dev/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
spring.profiles.active=dev
spring.config.import=classpath:common.properties

# logging
logging.level.com.codesquad.esfj.todolist.*=DEBUG
logging.level.root=info

# h2
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb;MODE=MYSQL;
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.datasource.initialization-mode=embedded
1 change: 1 addition & 0 deletions be/sidedish-be/src/main/resources-dev/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO test_table(TEST_VALUE) VALUES ('test')
7 changes: 7 additions & 0 deletions be/sidedish-be/src/main/resources-dev/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table
(
`ID` BIGINT AUTO_INCREMENT NOT NULL,
`TEST_VALUE` VARCHAR(200),
PRIMARY KEY (`ID`)
);
13 changes: 13 additions & 0 deletions be/sidedish-be/src/main/resources-prod/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
spring.profiles.active=prod
spring.config.import=classpath:common.properties

# logging
logging.level.com.codesquad.esfj.todolist.*=DEBUG
logging.level.root=info

# mysql
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/sidedish?serverTimezone=UTC&characterEncoding=UTF-8
spring.datasource.username=sidedish
spring.datasource.password=sidedish
spring.datasource.initialization-mode=always
1 change: 0 additions & 1 deletion be/sidedish-be/src/main/resources/application.properties

This file was deleted.

6 changes: 6 additions & 0 deletions be/sidedish-be/src/main/resources/common.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# logging
logging.file.path=logs/sidedish
spring.output.ansi.enabled=always

# server
server.port = 8081
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.sidedishbe;
package com.codesquad.sidedish;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down

0 comments on commit b0dd692

Please sign in to comment.