diff --git a/README.md b/README.md index fc4e5c5f..866e59e0 100644 --- a/README.md +++ b/README.md @@ -1 +1,18 @@ -# back \ No newline at end of file + +# Team_D+ + +## 기술 스택 +**`Back-end`** +- Java 8 +- SpringBoot +- Spring Security +- Gradle +- JPA +- Spring Data Jpa +- QueryDSL +- MySQL 8.0 +- gitAction - 추가예정 +- Beanstalk - 추가예정 +- AWS EC2 - 추가예정 +- AWS Redis - 추가예정 +- NgineX - 추가예정 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 55846701..e473c4c0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,13 @@ +buildscript { + ext { + queryDslVersion = "5.0.0" + } +} + plugins { id 'org.springframework.boot' version '2.6.4' id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" id 'java' } @@ -13,6 +20,9 @@ configurations { extendsFrom annotationProcessor } } +jar { + enabled = false +} repositories { mavenCentral() @@ -23,16 +33,47 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation group: 'org.json', name: 'json', version: '20090211' implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' + implementation "com.querydsl:querydsl-jpa:${queryDslVersion}" + implementation 'org.projectlombok:lombok:1.18.22' + implementation('com.h2database:h2') + + annotationProcessor "com.querydsl:querydsl-apt:${queryDslVersion}" + compileOnly 'org.projectlombok:lombok' + developmentOnly 'org.springframework.boot:spring-boot-devtools' + runtimeOnly 'com.h2database:h2' runtimeOnly 'mysql:mysql-connector-java' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' + + implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.2' + runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.2' + runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.2' } tasks.named('test') { useJUnitPlatform() } + +def querydslDir = "$buildDir/generated/querydsl" +querydsl { + jpa = true + querydslSourcesDir = querydslDir +} +sourceSets { + main.java.srcDir querydslDir +} +configurations { + querydsl.extendsFrom compileClasspath +} +compileQuerydsl { + options.annotationProcessorPath = configurations.querydsl +} diff --git a/src/main/java/TeamDPlus/code/CodeApplication.java b/src/main/java/TeamDPlus/code/CodeApplication.java index 09c2e40c..7148237f 100644 --- a/src/main/java/TeamDPlus/code/CodeApplication.java +++ b/src/main/java/TeamDPlus/code/CodeApplication.java @@ -1,13 +1,23 @@ package TeamDPlus.code; +import com.querydsl.jpa.impl.JPAQueryFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import javax.persistence.EntityManager; + +@EnableJpaAuditing @SpringBootApplication public class CodeApplication { public static void main(String[] args) { SpringApplication.run(CodeApplication.class, args); } + @Bean + JPAQueryFactory jpaQueryFactory(EntityManager entityManager) { + return new JPAQueryFactory(entityManager); + } } diff --git a/src/main/java/TeamDPlus/code/domain/BaseEntity.java b/src/main/java/TeamDPlus/code/domain/BaseEntity.java new file mode 100644 index 00000000..dde5e815 --- /dev/null +++ b/src/main/java/TeamDPlus/code/domain/BaseEntity.java @@ -0,0 +1,23 @@ +package TeamDPlus.code.domain; + +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.EntityListeners; +import javax.persistence.MappedSuperclass; +import java.time.LocalDateTime; + + +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +@Getter +public class BaseEntity { + + @CreatedDate + private LocalDateTime created; + + @LastModifiedDate + private LocalDateTime modified; +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b137891..00000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 00000000..66b1eabe --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,36 @@ +spring: + datasource: + #h2 setting + driver-class-name: org.h2.Driver + url: jdbc:h2:tcp://localhost/~/testdb + username: sa + password: + #mysql setting +# driver-class-name: com.mysql.cj.jdbc.Driver +# # DB Source +# url: +# # DB username +# username: +# # DB password +# password: + + + jpa: + hibernate: + ddl-auto: create + properties: + hibernate: + format_sql: true + default_batch_fetch_size: 1000 + + jwt: + header: Authorization + #hs256 알고리즘 32비트 이상의 시크릿키 + secret: #시크릿값 git ignore 필수 + + +logging.level: + org.hibernate.SQL: debug + +server: + port: 8081 \ No newline at end of file