JeongDaEun
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 돌다리 리뷰 spring # spring Spring이 생겨나게 된 이유? 역사를 살펴보면 (MVC) EJB -> webwork, structs, loxy -> spring MVC 이다. 우선 EJB의 경우 view에 data 접근하는 코드, 비지니스 로직등이 분리되지 않고 합쳐져있었다. 또한 파편화로 인해 개발자가 여러 방식을 이해하는데 많은 시간이 걸렸다. 따라서 비지니스 로직에 집중하기 어려웠다. > 특히 JSP는 너무 끔직했다. java와 html 코드가 같이 있다니.. 그로 인해 MVC가 나오게 되었는데 controller는 XML에 구현해야하는 등의 불편함이 있었고, 또한 점점 시대가 변화되면서 비지니스 로직이 거대해졌는데 이를 커버할 수 없게 되었다. > 비지니스 로직이 거대해지면서 자연스럽게 관심을 분리하고 책임을 나누고 유연하게 확장가능한 구조를 만들기 위해 고민했다고 한다. 따라서 스프링이 나오게 되었고 스프링은 제어의 주체자로써 개발자가 설정해놓은 파일을 통해 의존성을 주입하고 객체의 생명주기를 제어한다. 즉, 개발자가 비지니스 로직에 집중할 수 있게 되었다. > application-level business logic, application enterprise > 비지니스 로직에 집중할 수 있도록 되는 이유: web application의 경우(Spring MVC), ![](https://i.imgur.com/tr4t4xy.png) ![image](https://media.oss.navercorp.com/user/19259/files/93691980-e57e-11ea-8c44-e13194167ce3) 톰캣은 java servlet의 구현체로 servlet container의 역할을 해주며, 기존에는 개발자가 doGet() doPost()등 구현해야했는데 이미 스프링에서 dispatcher servlet으로 이를 구현해준다. > 톰캣이 실행됐을때, 서버의 80번 포트를 사용해서 request:80을 listen한다. 포트 번호는 중요하지 않다. 만약 8989를 사용하고 싶다면 사용해도 된다. http 요청을 처리할수 있는 로직이 8989을 사용하고 있으면 된다. > Spring Application: 이는 main에서 run 되며, java application이다. 자바는 동적으로 클래스를 읽어온다. 런타임에 모든 코드가 JVM에 링크된다. 모든 클래스는 그 클래스가 참조되는 순간에 동적으로 JVM에 링크되며, 메모리에 로딩된다. 이 작업은 class loader 시스템을 통해 이루어진다. annotation processor은 어노테이션을 해석하는데 이는 runtime에 해석할 수도 compile타임에 해석할 수도 있다. 보통은 컴파일 타임에 해석한다. 컴파일 타임에 클래스, 인터페이스, 필드, 메소드 이름을 알지 못하더라도 reflection을 통해 런타임에 클래스, 인터페이스, 필드, 메소드에 접근할 수 있다. reflection을 이용하면 필드, 생성자, 메소드에 적용된 annotation 정보를 읽어 주입할 수 있다. 따라서 이러한 메커니즘을 통해 DI, IOC가 이루어질 수 있다. AOP는 웹 개발을 하다보면 로그인관련 처리, xss 방어 등 공통적으로 처리해야할 업무들이 많다. 기존 oop의 중복 코드 단점을 해결하고자 나온 방식이다. 실행할 때 비즈니스 코드에 앞, 뒤 등 원하는 때에 공통 작업을 수행할 수 있게 하여 중복 코드를 줄인다. ![KakaoTalk_Photo_2020-07-11-16-37-18](https://media.oss.navercorp.com/user/19257/files/d1c2c480-c394-11ea-83f8-7462f3583d7c) instance <- object <- class class에 정의한 대로 오브젝트를 만든다. 어떤 상태인지 어떤 행동을 하는지 알 수 있다. 내가 생성한 오브젝트를 어떻게 참조할까? 인스턴스 개념이 들어간다. 인스턴스는 메모리와 주소를 할당받은 존재이다. 빈도 오브젝트이다. 스프링의 IoC방식으로 관리되는 오브젝트이다. > https://alfredjava.wordpress.com/2008/07/08/class-vs-object-vs-instance/ *인스턴스는 힙에 저장된다. 스프링의 가장 큰 특징은 싱글톤 패턴이라는 점이다. Java 서버환경때문에 이 패턴을 채택했다. 엔터프라이즈 시스템은 서버 하나당 최대 초당 수십~수백건의 request를 처리해야한다. Gc의 성능이 아무리 좋다 한들 한계가 있다. 그래서 인스턴스 한개를 만들어서 공유하는 것이다. 자바의 기본적인 싱글톤 패턴은 여러 문제점이 있다고 한다. 그래서 스프링은 직접 싱글톤 형태의 오브젝트를 만들고 관리하는 기능을 제공하는 싱글톤 레지스터리가 있다. === Application context === 오브젝트 factory === 빈 팩토리 === Ioc 컨테이너 Java EE (enterprise) Java SE (standard) Java ME (micro) : micro processor 같은 느낌이었다. POJO: old 플레인 자바 spring은 web apps, apps(daemon)2가지 형태가 있다. 우리 프로젝트는 tomcat을 사용하지 않는다. 자바를 실행할 뿐이다! 그래서 Dispatcher servlet이 존재하지 않는다. 해당 URL이 어느 컨트롤러가 처리하는지 알 수 있는 HandlerMapping이 일어나지 않는다. > 맞나요? 카프카 브로커 서버와 데이터를 주고 받는다. 마치 디비 서버에서 데이터를 주고 받듯이 lombok은 Annotation Processor를 이용한 컴파일 시점에 AST를 조작해서 바이트 코드를 삽입한다. 컴파일러는 AST를 생성 후 'javac-processor'에 등록된 Annotation Processor를 호출한다. Annotation Processor는 Syntax tree를 이용하거나 직접 visitor를 구현해 트리를 탐색하면서 필요한 데이터를 얻고 필요한 코드를 추가한다. javac는 .java를 .class로 바꾸는 컴파일러이다. 여기에는 3가지의 API 패키지가 있다. - Language Model API - Annotation Processing API - Compliler Tree API JVM은 클래스 로더, 실행시간 데이터 영역, 실행 엔진으로 구성된다. Class Loader: class file 및 libraries를 엮어서 JVM이 운영체제로부터 할당받은 메모리 영역인 Runtime Data Area로 로드한다. (바이트 코드로 컴파일 된다) Execution Engine: 바이트 코드(.class)를 기계어로 변경해 명령어 단위로 실행한다. Runtime Data Area: - 메소트 영역: 클래스 멤버 변수, 필드 정보, static 변수, final class 변수등이 생성되는 영역 - 힙 영역: 객체와 배열이 생성되는 영역 - Java 스택 영역: 메소드를 호출할 때마다 스레드별 스택이 생성된다. - program counter: 스레드가 생성될 때마다 생성되는 영역으로 다음에 실행할 명령어의 주소를 기억하는 CPU 레지스터이다. - native method stack: 자바 외 언어로 작성된 네이티브 코드를 위한 메모리영역 ![image](https://media.oss.navercorp.com/user/19259/files/83532a80-e4e9-11ea-8ccb-a81f31d1ff17) Garbage Collector: Heap 메모리 영역에 생성된 객체들 중에 참조되지 않는 객체들을 탐색 후 제거하는 역할을 하며 GC가 수행되는 동안 수행중인 쓰레드가 아닌 다른 모든 쓰레드가 일시정지 되는 특징이 있다. 오.. # spring HelloWorld ```java /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/bin/java -XX:TieredStopAtLevel=1 ... . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.3.3.RELEASE) Starting DemoApplication on AL01288473.local with PID 23873 No active profile set, falling back to default profiles: default Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' Tomcat initialized with port(s): 8080 (http) Starting service [Tomcat] Starting Servlet engine: [Apache Tomcat/9.0.37] Initializing Spring embedded WebApplicationContext Root WebApplicationContext: initialization completed in 645 ms Initializing ExecutorService 'applicationTaskExecutor' LiveReload server is running on port 35729 Tomcat started on port(s): 8080 (http) with context path '' Started DemoApplication in 1.227 seconds (JVM running for 7.747) ``` /hello 컨트롤러 추가 ```java package com.example.demo.web; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloWorldController { @RequestMapping("/hello") public String sayHello(@RequestParam(value = "name") String name){ return "Hello " + name + "!"; } } ``` 추가된 INFO log ```java ... Initializing Spring DispatcherServlet 'dispatcherServlet' Initializing Servlet 'dispatcherServlet' Completed initialization in 5 ms ``` ....음.. 메인부터 run 디버깅 차례차례 따라 갔는데요. DispatcherHandler 가 보이고 cl = Thread.currentThread().getContextClassLoader() javax.Servlet.Servlet org.springframework.web.context ConfigurableWebApplicationContext getSpringFactoriesInstances(ApplicationContextInitializer.class) getSpringFactoriesInstances(ApplicationListener.class) 아직 잘 모르겠습니다. 여러번 더 봐야할것 같습니다.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully