Giter Club home page Giter Club logo

spring-base's Introduction

Spring-base Coverage Reliability Rating Security Rating Maintainability Rating Vulnerabilities Code Smells

프로젝트 설명...

  • 개인 프로젝트에 사용 될 Spring-boot boiler plate입니다.
  • Template repository로 설정되어있습니다.

특징

🌐 전역적, 유지보수가 쉬운 에러 핸들링

  • 모든 에러에 대한 RFC 7807 spec response

🚪 Test Container

  • Test Container를 통해 격리된 한경에서 test 수행이 가능합니다.

📝 Github pages

  • Test 정보, api명세서등 document는 release가 publish되면 Github page에 자동으로 upload됩니다.

⚙️ Release note 자동화

  • Release가 되면 자동으로 workflow가 draft를 작성해줍니다.

⚙️ Sonar cloud를 통한 정적 분석

  • CI에서 Sonar cloud를 이용해 정적 분석을 진행합니다.
    • 해당 PR에서 추가된 source code에 대해 평가합니다.

Test 수행 시간 측정 및 export report

프로젝트 환경

  • Java version: 21
    • distribution: 'temuri
  • Gradle version: 8.7

환경변수

유효 프로퍼티

  • local_docker
  • local
  • dev
  • prod
  • test

환경변수 세팅

Intellij community

intellij-community-env

초기 설정

Github pages

main branch에서 아래 명령어를 입력 해 gh-pages branch로 checkout 합니다.

git checkout --orphan gh-pages

Important

gh-pages branch는 orphan branch입니다.

아래 명령어를 통해 git에 캐시된 정보를 모두 삭제합니다.

git rm --cached -r .

아래 명령어를 통해 Github pages 구성에 필요한 artifacts를 docs로 이동 합니다.

rm -rf docs
mkdir docs
cp -R gh-pages/docs ./

swagger-ui/dist/swagger-initializer.js를 열어 아래와 같이 수정합니다.

window.onload = function() {
  window.ui = SwaggerUIBundle({
    ...
    configUrl:"https://github-id.github.io/repository-name/swagger-ui/swagger-config.yaml",
    ...
  });
};

gh-pages에 push

git add docs
git commit -m "init"
git push origin gh-pages

이 다음 repository setting에 들어가서 github pages를 설정합니다.

github-repo-setting

github-gh-pages-deploy-setting

Gradle configuration cache 활성화

Configuration cache를 활성화 하는 경우 gradle-transforms을 캐싱할 수 있습니다.

Important

Github action secret에 GradleEncryptionKey이란 이름으로 secret key를 등록해야 활성화 됩니다.

  • Secret key가 없어도 정상 작동 합니다. 다만 configure cache는 무시됩니다.

ci.yml에서 아래 부분이 관련 코드입니다.

      - name: Set up gradle with gradle cache
        uses: gradle/actions/setup-gradle@v3
        continue-on-error: true
        with:
          # ...
          cache-encryption-key: ${{ secrets.GradleEncryptionKey }} # << github action secret 등록해야 활성화

      - name: Build
        run: gradle build --configuration-cache --info

Important

configuration cache를 암호화 시 AES-128 AES-192, AES-256을 기반으로 하기 때문에 16byte, 24byte, 32byte 중 하나로 secret을 설정해야 합니다.

Docker (설치)

  • mac x86에서만 확인되었습니다.

./init.sh 실행

./init.sh

Sonar cloud

Sonar cloud repository 설정

spring-base's People

Contributors

can019 avatar

Stargazers

 avatar

Watchers

 avatar

spring-base's Issues

Servlet exception handling

요구 사항

  • 전역적으로 처리되어야 한다.
  • 에러 로깅이 되어야 한다.
    • 에러 발생 message는 에러가 발생한 곳의 method input, line, class 정보를 포함해야 한다.
    • 에러 로깅은 한 번만 되야 한다.
  • 에러에 맞는 code, status, message가 client로 전달되어야 한다.
    • stack trace가 노출되면 안된다.
  • 존재하지 않는 요청은(404) body만 응답으로 주어야 한다.
  • Custom error가 추가될 수 있으므로 이를 반영할 수 있게 한다.

Spring context exception handling

요구 사항

  • 전역적으로 처리되어야 한다.
  • 에러 로깅이 되어야 한다.
    • 에러 발생 message는 에러가 발생한 곳의 method input, line, class 정보를 포함해야 한다.
    • 에러 로깅은 한 번만 되야 한다.
  • 에러에 맞는 code, status, message가 client로 전달되어야 한다.
    • stack trace가 노출되면 안된다.
  • Spring context에서의 exception은 was로 전파되면 안된다.
  • Custom error가 추가될 수 있으므로 이를 반영할 수 있게 한다.

Case

  • Controller에 정상적으로 도달했지만 해당 controller에서 response를 반환하기 전에 exception이 발생한 경우
  • Controller에서 response를 정상적으로 반환했지만 이 후 exception이 발생한 경우
    • Interceptor
    • DispatcherServlet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.