포트폴리오/ohouseClone

1. 기본 Intellj setting 및 db연결 & 칸반보드 작성

가끔개발 2023. 8. 11. 16:23

1. build.gradle 설정 

plugins {
    id 'java'
    id 'org.springframework.boot' version '2.7.14'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}

group = 'com.portfolio'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '11'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
    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.thymeleaf.extras:thymeleaf-extras-springsecurity5'
    implementation 'io.jsonwebtoken:jjwt-api:0.11.5'

    // queryDSL 설정
    implementation "com.querydsl:querydsl-jpa"
    implementation "com.querydsl:querydsl-core"
    implementation "com.querydsl:querydsl-collections"
    annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jpa" // querydsl JPAAnnotationProcessor 사용 지정
    annotationProcessor "jakarta.annotation:jakarta.annotation-api" // java.lang.NoClassDefFoundError (javax.annotation.Generated) 대응 코드
    annotationProcessor "jakarta.persistence:jakarta.persistence-api" // java.lang.NoClassDefFoundError (javax.annotation.Entity) 대응 코드

    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'com.mysql:mysql-connector-j'
    annotationProcessor 'org.projectlombok:lombok'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.security:spring-security-test'

    //JUnit4 추가
    testImplementation("org.junit.vintage:junit-vintage-engine") {
        exclude group: "org.hamcrest", module: "hamcrest-core"
    }
}

tasks.named('test') {
    useJUnitPlatform()
}
// Querydsl 설정부
def generated = 'src/main/generated'

// querydsl QClass 파일 생성 위치를 지정
tasks.withType(JavaCompile) {
    options.getGeneratedSourceOutputDirectory().set(file(generated))
}

// java source set 에 querydsl QClass 위치 추가
sourceSets {
    main.java.srcDirs += [ generated ]
}

// gradle clean 시에 QClass 디렉토리 삭제
clean {
    delete file(generated)
}

2. application.yml 설정 

debug: false
management.endpoints.web.exposure.include: "*"

logging.level:
  #    com.example.board: debug
  #    org.springframework.web.servlet: debug
  #    org.hibernate.type.descriptor.sql.BasicBinder: trace
  org.hibernate.SQL: debug


spring:
  datasource:
    url: jdbc:mysql://localhost:3306/OhouseDB
    username:
    password:
    driver-class-name : com.mysql.cj.jdbc.Driver


  jpa:
    open-in-view: false
    defer-datasource-initialization: true
    hibernate:
      ddl-auto: create
    show-sql: true
    properties:
      hibernate:
        format_sql: true
        default_batch_fetch_size: 100
  sql.init.mode: always
  data.rest:
    base-path: /api
    detection-strategy: annotated
  thymeleaf4:
    decoupledLogic: true
jwt:
  secret:

3. mysql 다운 및 설정

4. intellj mysql 연결 root 로 연결후  user ,db 권한 생성

show databases;

create database localdb;

create user 'db'@'localhost' identified by '비밀번호';
select `user` from `mysql`.`user`;
show grants for 'db'@'localhost';
grant all on `localdb`.* to 'db'@'localhost' with grant option;

flush privileges;

5. DB연결 확인 

6. ERD 분석

7. git Kanbanboard 제작