πŸ“š
TIL
  • README
  • Git
    • Basic
    • Remote Repository
    • Log & Diff
    • Rebase&Cherri-Pick
    • git-flow
  • DevOps
    • Monolithic vs MSA
    • Jenkins μ‹œμž‘ν•˜κΈ°
    • Airflow μ‹œμž‘ν•˜κΈ°
    • Airflow μ‹œμž‘ν•˜κΈ°
    • Build Tools
      • maven
  • 개발 방법둠
    • TDD
  • Spring
    • IoC
    • Is Spring Bean Thread-Safe?
    • Spring Singleton
    • Component Scan
    • Spring Annotation
    • 의쑴 관계 μ£Όμž…(DI)
    • Lombok ν™œμš©ν•˜κΈ°
    • Bean 생λͺ…주기와 콜백
    • Bean Scope
    • AOP(1) - AOPλž€
    • AOP(2) - Aop Proxy
    • AOP(3) - Dynamic Proxy
    • AOP(4) - AspectJ
    • POJO
    • Spring μ„œλΉ„μŠ€ ꡬ쑰
    • Transaction
    • JPAλž€?
    • JPA Entity
    • Spring Data JPA
    • Spring Data Specification
    • Model Mapping
    • Cache
    • restTemplate
    • YAML 파일 μ„€μ •
    • Spring Boot
      • H2 DB μ„€μ •
      • 닀쀑 λ°μ΄ν„°λ² μ΄μŠ€ μ„€μ •
      • Mybatis μ—°λ™ν•˜κΈ°
    • Spring Batch
      • Batch μ‹œμž‘ν•΄λ³΄κΈ°
      • Batch Job Flow
      • Job
      • Step
      • Batch Scope & Job Parameter
      • JobRepository와 λ©”νƒ€ν…Œμ΄λΈ”
      • Chunk μ§€ν–₯ ν”„λ‘œκ·Έλž˜λ°
      • ItemReader
      • ItemProcessor
      • ItemWriter
      • Batch Schedular
      • Job별 Beanλ“±λ‘ν•˜κΈ°
      • Batch κ΅¬ν˜„μ‹œ λ°œμƒν•œ 였λ₯˜ 정리
      • Spring Batch Scaling
        • Multithread Jobκ΅¬ν˜„μ‹œ μ΄μŠˆμ‚¬ν•­
    • Spring test
      • Junit5
        • ν…ŒμŠ€νŠΈ 이름 ν‘œκΈ°
        • ν…ŒμŠ€νŠΈ κ·Έλ£Ή μ‚¬μ΄μ˜ 관계
        • νƒœκ·Έμ™€ 필터링
        • 동적 ν…ŒμŠ€νŠΈ
        • ν…ŒμŠ€νŠΈ LifeCycle
        • ν…ŒμŠ€νŠΈ λ©”μ„œλ“œ
        • ν…ŒμŠ€νŠΈ μˆœμ„œ
        • AssertJ
        • ν…ŒμŠ€νŠΈ 병렬 μ‹€ν–‰
        • AssertJ
        • Mock
      • Spring Boot Test DB 뢄리
      • Spring Batch Test
  • Web Application
    • Web Server & WAS
    • κ΄€λ ¨ κ°œλ… - HTTP API, HTML, CSR, SSR
    • Servlet
    • JSP
    • Cookie And Session
    • μ˜ˆμ™ΈνŽ˜μ΄μ§€
    • Java Bean
    • JDBC
    • Connection Pool
    • 파일 μ—…λ‘œλ“œ
    • Expression Language
    • JSTL
    • FrontControllerνŒ¨ν„΄ Command νŒ¨ν„΄
    • Forwarding
    • MVC
    • νšŒμ›κ°€μž…μ˜ˆμ œ
    • μ°Έκ³ 
      • κ°œλ°œν™˜κ²½μ„€μ •
  • Java+
    • SOAP/WSDL vs REST
    • WSDL을 JAVA둜 λ³€ν™˜ν•˜κΈ°
    • SOAP 톡신 OPEN API둜 κ°œλ°œν•΄λ³΄κΈ°
  • Java
    • Basic
      • λ³€μˆ˜μ™€ νƒ€μž…
      • μ—°μ‚°μž
      • 쑰건문과 반볡문
      • μ°Έμ‘° νƒ€μž…
      • 클래슀
      • 상속(Inheritance)
      • μΈν„°νŽ˜μ΄μŠ€(Interface)
      • 쀑첩 ν΄λž˜μŠ€μ™€ 쀑첩 μΈν„°νŽ˜μ΄μŠ€
      • μ˜ˆμ™Έ 처리
      • API - Object, System, Class, Math, Wrapper
      • API - String, StringBuffer, StringBuilder
      • Thread
      • Generic
      • Lambda
      • Collection - List, Set
      • Collection - Map
      • Collection - Tree
      • Collection - Stack, Queue
      • Stream
      • Reflection
      • μ •κ·œν‘œν˜„μ‹
      • GUI
      • UML
      • Serializable
    • Advanced
      • OutOfMemoryError
      • AutoValue
      • meta-annotation
        • @Retention
        • @Target
        • @Repeatable
    • Effective Java 3/E
      • ITEM 1: Static Factory Method(정적 λ©”μ†Œλ“œ)
      • ITEM 2: Builder Pattern
      • ITEM 3: Singleton
      • ITEM 4: Private Constructor
      • ITEM 5: Dependency Injection
      • ITEM 6: Avoid Unnecessary Object
      • ITEM 7: Eliminate Object Reference
      • ITEM 8: Avoid finalizer and cleaner
      • ITEM 9: try-with-resources
      • ITEM 10: The gerneral contract when overriding equlas
      • ITEM 11: Overriding hashCode
      • ITEM 12: overriding toString
      • ITEM 13: overriding clone judiciously
      • ITEM 14: Consider implementing comparable
      • ITEM 15: ν΄λž˜μŠ€μ™€ λ©€λ²„μ˜ 접근을 μ΅œμ†Œν™”ν•΄λΌ
      • ITEM 16: Use Accessor methods
      • ITEM 17: λ³€κ²½ κ°€λŠ₯성을 μ΅œμ†Œν™”ν•΄λΌ(λΆˆλ³€ 클래슀)
      • ITEM 18: 상속보단 μ»΄ν¬μ§€μ…˜μ„ μ‚¬μš©ν•΄λΌ
      • ITEM 19: 상속을 κ³ λ €ν•΄ μ„€κ³„ν•˜κ³  λ¬Έμ„œν™”ν•΄λΌ
      • ITEM 20: 좔상 ν΄λž˜μŠ€λ³΄λ‹€ μΈν„°νŽ˜μ΄μŠ€λ₯Ό μš°μ„ ν•˜λΌ
      • ITEM 21: μΈν„°νŽ˜μ΄μŠ€λŠ” κ΅¬ν˜„ν•˜λŠ” μͺ½μ„ 생각해 섀계해라.
      • ITEM 22: μΈν„°νŽ˜μ΄μŠ€λŠ” νƒ€μž…μ„ μ •μ˜ν•˜λŠ” μš©λ„λ‘œλ§Œ μ‚¬μš©ν•΄λΌ
      • ITEM 23: νƒœκ·Έ 달린 ν΄λž˜μŠ€λ³΄λ‹€ 클래슀 계측ꡬ쑰λ₯Ό ν™œμš©ν•΄λΌ
      • ITEM 24: 멀버 ν΄λž˜μŠ€λŠ” λ˜λ„λ‘ static으둜 κ΅¬ν˜„ν•΄λΌ
      • ITEM 25: ν†±λ ˆλ²¨ ν΄λž˜μŠ€λŠ” ν•œ νŒŒμΌμ— ν•˜λ‚˜λ§Œ 생성해라.
      • ITEM 26: Raw type은 μ‚¬μš©ν•˜μ§€ 마라
      • ITEM 27: 비검사 κ²½κ³ λ₯Ό μ œκ±°ν•΄λΌ
      • ITEM 28: λ°°μ—΄λ³΄λ‹€λŠ” 리슀트λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 29: 이왕이면 μ œλ„€λ¦­ νƒ€μž…μœΌλ‘œ λ§Œλ“€μ–΄λΌ
      • ITEM 30: 이왕이면 μ œλ„€λ¦­ λ©”μ„œλ“œλ‘œ λ§Œλ“€μ–΄λΌ
      • ITEM 31 : ν•œμ •μ  μ™€μΌλ“œμΉ΄λ“œλ₯Ό μ‚¬μš©ν•΄ API μœ μ—°μ„±μ„ 높여라
      • ITEM 32: μ œλ„€λ¦­κ³Ό κ°€λ³€μΈμˆ˜λ₯Ό ν•¨κ»˜ μ“Έ λ•ŒλŠ” 신쀑해라
      • ITEM 33: νƒ€μž… μ•ˆμ „ 이쒅 μ»¨ν…Œμ΄λ„ˆλ₯Ό 고렀해라
      • ITEM 34: int μƒμˆ˜ λŒ€μ‹  μ—΄κ±° νƒ€μž…μ„ μ‚¬μš©ν•΄λΌ
      • ITEM 35: ordinal λ©”μ„œλ“œ λŒ€μ‹  μΈμŠ€ν„΄μŠ€ ν•„λ“œλ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 36: λΉ„νŠΈ ν•„λ“œ λŒ€μ‹  EnumSet을 μ‚¬μš©ν•΄λΌ
      • ITEM 37: ordinal 인덱싱 λŒ€μ‹  EnumMap을 μ‚¬μš©ν•΄λΌ
      • TEM 38 : ν™•μž₯ν•  수 μžˆλŠ” μ—΄κ±°νƒ€μž…μ΄ ν•„μš”ν•˜λ©΄ μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 39: λͺ…λͺ… νŒ¨ν„΄λ³΄λ‹€ μ• λ„ˆν…Œμ΄μ…˜μ„ μ‚¬μš©ν•΄λΌ
      • ITEM 40: @Override μ–΄λ…Έν…Œμ΄μ…˜μ„ μΌκ΄€λ˜κ²Œ μ‚¬μš©ν•΄λΌ
      • ITEM 41: μ •μ˜ν•˜λ €λŠ” 것이 νƒ€μž…μ΄λΌλ©΄ 마컀 μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 42: 읡λͺ… ν΄λž˜μŠ€λ³΄λ‹€λŠ” λžŒλ‹€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 43: λžŒλ‹€λ³΄λ‹€λŠ” λ©”μ„œλ“œ μ°Έμ‘°λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 44: ν‘œμ€€ ν•¨μˆ˜ν˜• μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 45: μŠ€νŠΈλ¦Όμ€ μ£Όμ˜ν•΄μ„œ μ‚¬μš©ν•΄λΌ
      • ITEM 46: μŠ€νŠΈλ¦Όμ—μ„œ λΆ€μž‘μš© μ—†λŠ” ν•¨μˆ˜λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 47: λ°˜ν™˜ νƒ€μž…μœΌλ‘œλŠ” μŠ€νŠΈλ¦Όλ³΄λ‹€ μ»¬λ ‰μ…˜μ΄ λ‚«λ‹€.
      • ITEM 48: 슀트림 λ³‘λ ¬ν™”λŠ” μ£Όμ˜ν•΄μ„œ μ‚¬μš©ν•΄λΌ
      • ITEM 49: λ§€κ°œλ³€μˆ˜κ°€ μœ νš¨ν•œμ§€ 검사해라
      • ITEM 50: μ μ‹œμ— 방어적 볡사본을 λ§Œλ“€μ–΄λΌ
      • ITEM 51: λ©”μ„œλ“œ μ‹œκ·Έλ‹ˆμ²˜λ₯Ό μ‹ μ€‘νžˆ 섀계해라
      • ITEM 52: λ‹€μ€‘μ •μ˜λŠ” μ‹ μ€‘νžˆ μ‚¬μš©ν•΄λΌ
      • ITEM 53: κ°€λ³€μΈμˆ˜λŠ” μ‹ μ€‘νžˆ μ‚¬μš©ν•΄λΌ
      • ITEM 54: null이 μ•„λ‹Œ, 빈 μ»¬λ ‰μ…˜μ΄λ‚˜ 배열을 λ°˜ν™˜ν•΄λΌ
      • ITEM 55: Optional λ°˜ν™˜μ€ μ‹ μ€‘ν•˜κ²Œ 해라
      • ITEM 56: 곡개된 API μš”μ†Œμ—λŠ” 항상 주석을 μž‘μ„±ν•΄λΌ
      • ITEM 57: μ§€μ—­λ³€μˆ˜μ˜ λ²”μœ„λ₯Ό μ΅œμ†Œν™”ν•΄λΌ
      • ITEM 58: 전톡적인 for λ¬Έλ³΄λ‹€λŠ” for-each문을 μ‚¬μš©ν•΄λΌ
      • ITEM 59: 라이브러리λ₯Ό 읡히고 μ‚¬μš©ν•΄λΌ
      • ITEM 60: μ •ν™•ν•œ 닡이 ν•„μš”ν•˜λ‹€λ©΄ float와 double은 피해라
      • ITEM 61: λ°•μ‹±λœ κΈ°λ³Έ νƒ€μž…λ³΄λ‹€λŠ” κΈ°λ³Έ νƒ€μž…μ„ μ‚¬μš©ν•΄λΌ
      • ITEM 62: λ‹€λ₯Έ νƒ€μž…μ΄ μ μ ˆν•˜λ‹€λ©΄ λ¬Έμžμ—΄ μ‚¬μš©μ„ 피해라
      • ITEM 63: λ¬Έμžμ—΄ 연결은 λŠλ¦¬λ‹ˆ μ£Όμ˜ν•΄λΌ
      • ITEM 64: κ°μ²΄λŠ” μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄ 참쑰해라
      • ITEM 65: λ¦¬ν”Œλ ‰μ…˜λ³΄λ‹€λŠ” μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 66: λ„€μ΄ν‹°λΈŒ λ©”μ„œλ“œλŠ” μ‹ μ€‘νžˆ μ‚¬μš©ν•΄λΌ
      • ITEM 67: μ΅œμ ν™”λŠ” μ‹ μ€‘νžˆ 해라
      • ITEM 68: 일반적으둜 ν†΅μš©λ˜λŠ” λͺ…λͺ… κ·œμΉ™μ„ 따라라
    • 객체지ν–₯ 섀계 원칙(SOLID)
    • λ””μžμΈνŒ¨ν„΄
      • Strategy Pattern
      • Template Method Pattern
      • Factory Method Pattern
      • Singleton
      • Delegation
      • Proxy
      • Adapter Pattern
    • μ‹€μŠ΅
      • μΈν„°νŽ˜μ΄μŠ€ μ‹€μŠ΅ - Vehicle
      • μΈν„°νŽ˜μ΄μŠ€ μ‹€μŠ΅ - Remote
      • GUI μ‹€μŠ΅ - Calculator
      • GUI μ‹€μŠ΅ - button
      • GUI μ‹€μŠ΅ - lotto
      • Thread μ‹€μŠ΅ - μ’Œμ„μ˜ˆμ•½, 메세지보내기
    • Jar vs War
  • λ°μ΄ν„°λ² μ΄μŠ€
    • KEY
    • Index
    • Transaction
    • Trigger
    • Procedure / Function
    • Package
    • λ°μ΄ν„°λ² μ΄μŠ€ 배움터
      • λ°μ΄ν„°λ² μ΄μŠ€ μ‹œμŠ€ν…œ
      • 관계데이터 λͺ¨λΈ
      • κ΄€κ³„λŒ€μˆ˜μ™€ SQL
    • MySQL
      • Databaseλž€
      • MySQL μ‹œμž‘ν•˜κΈ°
      • MySQL Database
      • MySQL Table
      • CRUD
      • κ΄€κ³„ν˜• λ°μ΄ν„°λ² μ΄μŠ€
      • Server와 Client
    • PostgreSQL
    • NoSQL
      • Install Cassandra on mac
      • Cassandraλž€?
      • NiFiλž€
  • Algorithm
    • String
    • Recursion
    • Dynamic Programming
    • Array, Struct, Pointer
    • Math
    • Sort
    • List
    • Stack
    • Queue
    • Graph
    • Tree
    • Maze
    • AVL
    • μ΄μ§„νƒμƒ‰νŠΈλ¦¬(Binary Search Tree)
    • DFS와 BFS
    • λ‹€μ΅μŠ€νŠΈλΌ μ•Œκ³ λ¦¬μ¦˜(Dijkstra's Algorithm)
    • Red-Black 트리
    • A* μ•Œκ³ λ¦¬μ¦˜
    • Heap
    • Huffman Coding
    • Priority Queue
    • Bellman-Ford μ•Œκ³ λ¦¬μ¦˜
    • C++
      • Class
      • STL
        • STL pair
        • STL Container - Associate Container
        • STL Container - Sequence Container
        • STL Container - Container Adapter
  • JavaScript
    • JABASCRIPT BASIC
    • Shallow Copy vs Deep Copy
    • OBJECT MODEL
    • NODE
    • 동기 처리 vs 비동기 처리
    • AJAX
    • CALLBACK
    • PROMISE
    • DEFERRER
    • UNDERSCORE
    • WEBPACK
    • SCOPE
    • EXECUTION CONTEXT
    • Image Object
    • BFCacheλž€?
    • history.scrollRestoration
    • Intersection Observer
    • JWT - JSON Web Token
    • HTML vs JSON
  • Vue.js
    • ν™˜κ²½μ„€μ •
    • Vue.jsλž€?
    • Vue Instance
    • Vue Component
    • Vue Router
    • HTTP 톡신
    • Template
    • Single File Component
    • Vue Animation
    • Vuex
    • Djnago와 μ—°λ™ν•˜κΈ°
  • Backbone.js
    • Model
    • Collection
    • Sync
    • view
  • Node.js
    • Doit! - λ…Έλ“œλ‘œ λ§Œλ“€ 수 μžˆλŠ” λŒ€ν‘œμ μΈ μ„œλ²„μ™€ μš©λ„
    • Doit! - λ…Έλ“œμ— λŒ€ν•΄ μ•Œμ•„λ³΄κ³  개발 도ꡬ μ„€μΉ˜ν•˜κΈ°
    • Doit! - λ…Έλ“œ κ°„λ‹¨ν•˜κ²Œ μ‚΄νŽ΄λ³΄κΈ°
    • Doit! - λ…Έλ“œμ˜ μžλ°”μŠ€ν¬λ¦½νŠΈμ™€ μΉœν•΄μ§€κΈ°
    • Doit! - λ…Έλ“œμ˜ κΈ°λ³Έ κΈ°λŠ₯ μ•Œμ•„λ³΄κΈ°
    • Doit! - μ›Ή μ„œλ²„ λ§Œλ“€κΈ°
    • Doit! - λ°μ΄ν„°λ² μ΄μŠ€ μ‚¬μš©ν•˜κΈ°
    • Doit! - μ΅μŠ€ν”„λ ˆμŠ€ ν”„λ‘œμ νŠΈλ₯Ό λͺ¨λ“ˆν™”ν•˜κΈ°
    • Doit! - λ·° ν…œν”Œλ¦Ώ μ μš©ν•˜κΈ°
    • Doit! - 패슀포트둜 μ‚¬μš©μž μΈμ¦ν•˜κΈ°
    • Doit! - μ±„νŒ…μ„œλ²„ λ§Œλ“€κΈ°
    • Doit! - JSON-RPC μ„œλ²„ λ§Œλ“€κΈ°
  • Python
    • Warning-Could not import the lzma module
    • Pandas
      • Pandas 자료ꡬ쑰
      • Pandas 데이터 μž…μΆœλ ₯
      • DataFrame Data μ‚΄νŽ΄λ³΄κΈ°
      • μ‹œκ°ν™” 도ꡬ - Matplotlib
  • ML
    • μΆ”μ²œ μ‹œμŠ€ν…œ
      • Collaborative Filtering
      • Matrix Factorization
  • Django
    • Basic
      • ν™˜κ²½μ„€μ •
      • About Django
      • Start Django Project
      • Secret Key κ΄€λ¦¬ν•˜κΈ°
      • Settings λΆ„λ¦¬ν•˜κΈ°
      • Django App
      • Django View & URL (1)
      • Django Model
        • MySQL 연동
      • Django Admin
      • Django View & URL (2)
      • Django Template
      • Django Template & View & URL
      • Django Static
      • Django form
    • Advanced
      • Django Generic View
      • Django Automated Testing
      • Django Extenstion Template
      • Django Model Package
      • Django OpenSSL setting
    • REST framework
      • Rest API
      • Serializers
      • ViewSet
    • Error
      • ν™˜κ²½μ„€μ • zlib 였λ₯˜λ°œμƒ
      • ModuleNotFoundError
    • νŒ¨ν‚€μ§€
      • django-debug-toolbar
    • Vue.js μ—°λ™ν•˜κΈ°
  • Ruby
    • variable & input/output
    • 쑰건문
    • 반볡문
    • Array & Hash
    • Method
    • Proc&Lamda
    • Class
  • Ruby on Rails
    • Scaffolding
    • Controller
    • Model
    • Model-M:N relation
    • Model Validation
    • 멋사 10μ£Όμ°¨ μˆ˜μ—…(Tip)
  • HTML/CSS
    • Udacity - Intro to HTML/CSS
    • Udacity - Responsive Web Design
    • Udacity - Responsive Images
    • HTML Basic
    • CSS Basic
    • HTML5 Sementic Tag
    • HTML ν…μŠ€νŠΈ κ΄€λ ¨ νƒœκ·Έλ“€
    • HTML5 λ©€ν‹°λ―Έλ””μ–΄
    • HTML 폼 κ΄€λ ¨ νƒœκ·Έλ“€
    • ν…μŠ€νŠΈ κ΄€λ ¨ μŠ€νƒ€μΌ
    • 색상과 배경을 μœ„ν•œ μŠ€νƒ€μΌ
    • λ ˆμ΄μ•„μ›ƒμ„ μœ„ν•œ μŠ€νƒ€μΌ
    • CSS 포지셔닝
    • λ‹€μž¬λ‹€λŠ₯ν•œ CSS3 μ„ νƒμž
    • CSS와 μ• λ‹ˆλ©”μ΄μ…˜
    • λ°˜μ‘ν˜• μ›Ήμ΄λž€?
  • OS(운영체제)
    • Linux
      • Daemon
      • Cron
      • ν”„λ‘œμ„ΈμŠ€ κ΄€λ ¨ λͺ…λ Ήμ–΄
      • ν…μŠ€νŠΈ 파일 λͺ…λ Ήμ–΄
  • Network
    • λ„€νŠΈμ›Œν¬ κΈ°λ³Έ κ°œλ…
    • λ„€νŠΈμ›Œν¬ κΈ°λ³Έ κ·œμΉ™
    • 물리 계측
    • 데이터 링크 계측
    • λ„€νŠΈμ›Œν¬ 계측
    • 전솑 계측
    • μ‘μš© 계측
    • λ„€νŠΈμ›Œν¬ 전체 흐름
    • 무선 랜
  • IT 기타지식
    • NASλž€
Powered by GitBook
On this page
  • FilterType μ˜΅μ…˜
  • @ComponentScan ꢌμž₯ μœ„μΉ˜
  • @ComponentScan ꢌμž₯ μœ„μΉ˜
  • @ComponentScan λŒ€μƒ
  • 쀑볡 등둝과 좩돌
  • ν…ŒμŠ€νŠΈ μ½”λ“œλ‘œ 확인
  • κΈ°λ³Έ @ComponentScan λΉˆλ“±λ‘ 확인
  • μ˜ˆμ™Έ/포함 확인
  • μ°Έκ³ 

Was this helpful?

  1. Spring

Component Scan

μŠ€ν”„λ§ λΉˆμ„ 등둝할 λ•ŒλŠ” μžλ°” μ½”λ“œμ˜ @Beanμ΄λ‚˜ XML의 <bean> 등을 ν†΅ν•΄μ„œ μ„€μ • 정보에 직접 등둝할 μŠ€ν”„λ§ λΉˆμ„ λ‚˜μ—΄ν•˜μ—¬ 등둝할 수 μžˆλ‹€. ν•˜μ§€λ§Œ μ΄λ ‡κ²Œ 등둝해야 ν•  μŠ€ν”„λ§ 빈이 μˆ˜μ‹­, μˆ˜λ°±κ°œκ°€ 되면 일일이 λ“±λ‘ν•˜κΈ°λ„ νž˜λ“€λ©°, μ„€μ • 정보도 컀지고, λˆ„λ½ν•˜λŠ” λ¬Έμ œλ„ λ°œμƒν•œλ‹€.

@Configuration
public class AppConfig {

    @Bean
    public MemberService memberService() {
        return new MemberServiceImpl(memberRepository());
    }

    @Bean
    public MemberRepository memberRepository() {
        return new MemoryMemberRepository();
    }
}

μŠ€ν”„λ§μ€ μ„€μ • 정보가 없어도 μžλ™μœΌλ‘œ μŠ€ν”„λ§ λΉˆμ„ λ“±λ‘ν•˜λŠ” μ»΄ν¬λ„ŒνŠΈ μŠ€μΊ”μ΄λΌλŠ” κΈ°λŠ₯을 μ œκ³΅ν•œλ‹€.

@ComponentScan : @Component μ–΄λ…Έν…Œμ΄μ…˜μ΄ 뢙은 λΉˆμ„ λ‹€ 등둝해쀀닀.

  • excludeFilters : μ œμ™Έν•  Component μ„€μ •

  • includeFilters : 포함할 Component μ„€μ •

  • basePackages : 탐색할 κΈ°λ³Έ νŒ¨ν‚€μ§€ 경둜(μ„€μ • μ•ˆν•œ 경우 ν•΄λ‹Ή μ–΄λ…Έν…Œμ΄μ…˜ νŒ¨ν‚€μ§€ ν•˜μœ„λ‘œ μ„€μ •)

    • basePackages = {"dh0023.springcore.order", "dh0023.springcore.member"} : μ—¬λŸ¬ μ‹œμž‘ μœ„μΉ˜ μ§€μ •κ°€λŠ₯

  • basePackageClassses : μ§€μ •ν•œ 클래슀의 νŒ¨ν‚€μ§€λ₯Ό 탐색 μ‹œμž‘ μœ„μΉ˜λ‘œ μ§€μ •(default : @ComponentScan 이 뢙은 μ„€μ • 정보 클래슀 νŒ¨ν‚€μ§€ ν•˜μœ„λ‘œ μ„€μ •)

package dh0023.springcore.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;

/**
 * @ComponentScan은 @Component μ–΄λ…Έν…Œμ΄μ…˜μ΄ 뢙은 클래슀λ₯Ό 빈으둜 등둝해쀀닀.
 * κΈ°λ³ΈνŒ¨ν‚€μ§€λ₯Ό μ„€μ •ν•΄μ£Όμ§€ μ•ŠμœΌλ©΄, ν˜„μž¬ νŒ¨ν‚€μ§€ ν•˜μœ„λ‘œ μ„€μ •λœλ‹€.
 * μ˜ˆμ™Έν•˜κ³  싢은 ν΄λž˜μŠ€κ°€ μžˆλŠ” 경우 excludeFilters둜 μ„€μ •ν•  수 μžˆλ‹€.
 */
@Configuration
@ComponentScan(
        basePackages = "dh0023.springcore",
        excludeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Configuration.class)
)
public class AutoAppConfig {

}

그러면 μ˜μ‘΄κ΄€κ³„λŠ” μ–΄λ–»κ²Œ μ£Όμž…ν•˜λŠ” 걸까? @Autowired 둜 μ˜μ‘΄κ΄€κ³„λ₯Ό μžλ™μœΌλ‘œ μ£Όμž…ν•  수 μžˆλ‹€.

@Bean 으둜 생성해 직접 μ˜μ‘΄κ΄€κ³„λ₯Ό μ„€μ •ν•˜λ˜ μ½”λ“œμ—μ„œ, @Component 와 @Autowired 만으둜 μ˜μ‘΄κ΄€κ³„μ™€ 빈으둜 등둝할 수 μžˆλ‹€.

package dh0023.springcore.member.service;

import dh0023.springcore.member.domain.Member;
import dh0023.springcore.member.repository.MemberRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MemberServiceImpl implements MemberService{

    /**
     * μƒμ„±μž DIλ₯Ό 톡해 κ΅¬ν˜„ν΄λž˜μŠ€ μ˜μ‘΄μ„± 제거 => μ‹€ν–‰μ—λ§Œ 집쀑 κ°€λŠ₯
     */
    private final MemberRepository memberRepository;

      /**
       * Autowired둜 μžλ™ μ˜μ‘΄κ΄€κ³„ μ£Όμž… κ°€λŠ₯
     */
    @Autowired
    public MemberServiceImpl(MemberRepository memberRepository) {
        this.memberRepository = memberRepository;
    }
}
  • λ³„λ„λ‘œ 빈 이름을 μ„€μ •ν•˜κ³  싢은 κ²½μš°μ—λŠ” @Component("μ„€μ •ν•  빈 이름") κ³Ό 같이 μ„€μ •ν•  수 μžˆλ‹€.

  • @Autowired λ₯Ό μ§€μ •ν•˜λ©΄ μŠ€ν”„λ§ μ»¨ν…Œμ΄λ„ˆκ°€ ν•΄λ‹Ή μŠ€ν”„λ§ λΉˆμ„ μ°Ύμ•„μ„œ μ£Όμž…ν•˜λŠ”λ° μ΄λ•Œ, νƒ€μž…μ΄ 같은 λΉˆμ„ μ°Ύμ•„μ„œ μ£Όμž…μ„ ν•œλ‹€.

FilterType μ˜΅μ…˜

type

μ„€λͺ…

예

ANNOTATION

default μ–΄λ…Έν…Œμ΄μ…˜μ„ μΈμ‹ν•΄μ„œ λ™μž‘

type = FilterType.ANNOTATION, classes = Configuration.class

ASSIGNABLE_TYPE

μ§€μ •ν•œ νƒ€μž…κ³Ό μžμ‹ νƒ€μž…μ„ μΈμ‹ν•΄μ„œ λ™μž‘ 클래슀 직접 μ§€μ •

org.example.ExampleService

ASPECTJ

AspectJ νŒ¨ν„΄ μ‚¬μš©

org.example..*Service+

REGEX

μ •κ·œ ν‘œν˜„μ‹

org.example.Default.*

CUSTOM

TypeFilter μ΄λΌλŠ” μΈν„°νŽ˜μ΄μŠ€λ₯Ό κ΅¬ν˜„ν•΄μ„œ 처리

org.example.MyTypeFilter

@ComponentScan ꢌμž₯ μœ„μΉ˜

@ComponentScan ꢌμž₯ μœ„μΉ˜

νŒ¨ν‚€μ§€ μœ„μΉ˜λ₯Ό λ³„λ„λ‘œ μ§€μ •ν•˜μ§€ μ•Šκ³ , μ„€μ • 정보 클래슀 μœ„μΉ˜λ₯Ό ν”„λ‘œμ νŠΈ μ΅œμƒλ‹¨μ— λ‘λŠ” 것을 ꢌμž₯ν•œλ‹€.(μŠ€ν”„λ§ λΆ€νŠΈλ„ 이 λ°©λ²•μœΌλ‘œ μ‹œμž‘)

ν”„λ‘œμ νŠΈ 메인 μ„€μ • μ •λ³΄λŠ” ν”„λ‘œμ νŠΈλ₯Ό λŒ€ν‘œν•˜λŠ” 정보이기 λ•Œλ¬Έμ— ν”„λ‘œμ νŠΈ μ‹œμž‘ 루트 μœ„μΉ˜μ— λ‘λŠ” 것을 ꢌμž₯ν•œλ‹€.

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
        @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {

    /**
     * Exclude specific auto-configuration classes such that they will never be applied.
     * @return the classes to exclude
     */
    @AliasFor(annotation = EnableAutoConfiguration.class)
    Class<?>[] exclude() default {};

    /**
     * Exclude specific auto-configuration class names such that they will never be
     * applied.
     * @return the class names to exclude
     * @since 1.3.0
     */
    @AliasFor(annotation = EnableAutoConfiguration.class)
    String[] excludeName() default {};
  ...
}

μŠ€ν”„λ§ λΆ€νŠΈλ₯Ό μ‚¬μš©ν•˜λ©΄ μŠ€ν”„λ§ λΆ€νŠΈμ˜ λŒ€ν‘œ μ‹œμž‘ 정보인 @SpringBootApplication μ•ˆμ— @ComponentScan 이 ν¬ν•¨λ˜μ–΄μžˆμœΌλ©°, 보톡 μ΅œμƒλ‹¨μ— ν•΄λ‹Ή ν΄λž˜μŠ€κ°€ μœ„μΉ˜ν•΄μžˆλ‹€.

@ComponentScan λŒ€μƒ

@Component 뿐만 μ•„λ‹ˆλΌ λ‹€λ₯Έ μ–΄λ…Έν…Œμ΄μ…˜λ“€λ„ μΆ”κ°€λ‘œ λŒ€μƒμ— ν¬ν•¨λœλ‹€.

예λ₯Ό λ“€μ–΄ @Configuration μ–΄λ…Έν…Œμ΄μ…˜μ„ μ‚΄νŽ΄λ³΄μž.

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Configuration {
    //...
}

ν•΄λ‹Ή μ–΄λ…Έν…Œμ΄μ…˜ 내뢀에 @Component μ–΄λ…Έν…Œμ΄μ…˜μ„ ν¬ν•¨ν•˜κ³  μžˆλŠ” 것을 λ³Ό 수 μžˆλ‹€. @ComponentScan 은 @Component μ–΄λ…Έν…Œμ΄μ…˜μ΄ λΆ™μ–΄μžˆλŠ” ν΄λž˜μŠ€λŠ” λͺ¨λ‘ 빈으둜 λ“±λ‘ν•˜λ―€λ‘œ, @Controller, @Service, @Repository λ“±λ“± μ–΄λ…Έν…Œμ΄μ…˜μ΄ 뢙은 ν΄λž˜μŠ€λ„ 빈으둜 λ“±λ‘ν•˜λŠ” 것을 μ•Œ 수 μžˆλ‹€.

  • μ–΄λ…Έν…Œμ΄μ…˜μ—λŠ” μƒμ†κ΄€κ³„λΌλŠ” 것이 μ—†μœΌλ©°, νŠΉμ • μ• λ…Έν…Œμ΄μ…˜μ„ λ“€κ³  μžˆλŠ” 것을 인식할 수 μžˆλŠ” 것은 μžλ°” μ–Έμ–΄κ°€ μ§€μ›ν•˜λŠ” κΈ°λŠ₯은 μ•„λ‹ˆκ³ , μŠ€ν”„λ§μ΄ μ§€μ›ν•˜λŠ” κΈ°λŠ₯이닀.

쀑볡 등둝과 좩돌

μžλ™λΉˆλ“±λ‘ vs μžλ™ λΉˆλ“±λ‘

μ»΄ν¬λ„ŒνŠΈ μŠ€μΊ”μ— μ˜ν•΄ μžλ™μœΌλ‘œ μŠ€ν”„λ§ 빈이 λ“±λ‘λ˜λŠ”λ°, κ·Έ 이름이 같은 경우 μŠ€ν”„λ§μ€ ConflictingBeanDefinitionException μ˜ˆμ™Έ λ°œμƒμ‹œν‚¨λ‹€.

μ΄λŸ¬ν•œ κ²½μš°λŠ” 거의 λ°œμƒν•˜μ§€ μ•ŠλŠ”λ‹€.

μˆ˜λ™ 빈 등둝 vs μžλ™ 빈 등둝

@Component
public class MemoryMemberRepository implements MemberRepository {}
@Configuration
@ComponentScan(
      excludeFilters = @Filter(type = FilterType.ANNOTATION, classes = Configuration.class)
)
public class AutoAppConfig {

      @Bean(name = "memoryMemberRepository")
    public MemberRepository memberRepository() {
            return new MemoryMemberRepository();
    }
}

같은 μ΄λ¦„μœΌλ‘œ μˆ˜λ™λΉˆκ³Ό μžλ™λΉˆμ΄ λ“±λ‘λœ κ²½μš°μ—λŠ”, μˆ˜λ™ λΉˆλ“±λ‘μ΄ μš°μ„ κΆŒμ„ κ°€μ§„λ‹€.

Overriding bean definition for bean 'memoryMemberRepository' with a different
definition: replacing

μˆ˜λ™λΉˆμ΄ μžλ™ λΉˆμ„ μ˜€λ²„λΌμ΄λ”© ν•œλ‹€.

졜근 μŠ€ν”„λ§ λΆ€νŠΈμ—μ„œλŠ” μˆ˜λ™ 빈 등둝과 μžλ™ 빈 λ“œμ˜­μ΄ μΆ©λŒλ‚˜λ©΄ 였λ₯˜κ°€ λ°œμƒν•˜λ„λ‘ κΈ°λ³Έ 값을 λ°”κΎΈμ—ˆμœΌλ©°, λ§Œμ•½ μ˜€λ²„λΌμ΄λ”©μ„ κ°€λŠ₯ν•˜κ²Œ ν•˜κ³  μ‹ΆμœΌλ©΄ spring.main.allow-bean-definition-overriding=true 둜 μ˜΅μ…˜μ„ μ„€μ •ν•˜λΌκ³  κ°€μ΄λ“œλ₯Ό μ£Όκ³  μžˆλ‹€.

Consider renaming one of the beans or enabling overriding by setting
spring.main.allow-bean-definition-overriding=true

ν…ŒμŠ€νŠΈ μ½”λ“œλ‘œ 확인

κΈ°λ³Έ @ComponentScan λΉˆλ“±λ‘ 확인

package dh0023.springcore.scan;

import dh0023.springcore.config.AutoAppConfig;
import dh0023.springcore.member.service.MemberService;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class AutoAppConfigTest {

    @Test
    void basicScan() {
        ApplicationContext ac = new AnnotationConfigApplicationContext(AutoAppConfig.class);

        MemberService memberService = ac.getBean(MemberService.class);

        Assertions.assertThat(memberService).isInstanceOf(MemberService.class);
    }
}
23:44:34.697 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerProcessor'
23:44:34.701 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
23:44:34.713 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
23:44:34.716 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
23:44:34.739 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'autoAppConfig'
23:44:34.748 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'rateDiscountPolicy'
23:44:34.749 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'memoryMemberRepository'
23:44:34.750 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'memberServiceImpl'
23:44:34.858 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Autowiring by type from bean name 'memberServiceImpl' via constructor to bean named 'memoryMemberRepository'
23:44:34.860 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'orderServiceImpl'
23:44:34.865 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Autowiring by type from bean name 'orderServiceImpl' via constructor to bean named 'memoryMemberRepository'
23:44:34.866 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Autowiring by type from bean name 'orderServiceImpl' via constructor to bean named 'rateDiscountPolicy'

둜그λ₯Ό 보면 singleton bean이 λ“±λ‘λ˜λŠ” 것을 λ³Ό 수 있으며, Autowired도 확인할 수 μžˆλ‹€.

μ˜ˆμ™Έ/포함 확인

  • MyExcludeComponent

package dh0023.springcore.scan.filter;

import java.lang.annotation.*;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyExcludeComponent {
}
  • MyIncludeComponent

package dh0023.springcore.scan.filter;

import java.lang.annotation.*;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyIncludeComponent {
}
  • BeanA

package dh0023.springcore.scan.filter;

@MyIncludeComponent
public class BeanA {
}
  • BeanB

package dh0023.springcore.scan.filter;

@MyExcludeComponent
public class BeanB {
}
  • Test

package dh0023.springcore.scan.filter;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;

public class ComponentFilterAppConfigTest {

    @Test
    void filterScan() {
        ApplicationContext ac = new AnnotationConfigApplicationContext(ComponentFilterAppConfig.class);

        BeanA beanA = ac.getBean("beanA", BeanA.class);
        assertThat(beanA).isNotNull();

        assertThrows(
                NoSuchBeanDefinitionException.class, () -> ac.getBean("beanB", BeanB.class)
        );


    }

    @Configuration
    @ComponentScan(
            includeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = MyIncludeComponent.class),
            excludeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = MyExcludeComponent.class)
    )
    static class ComponentFilterAppConfig {
    }
}

μ°Έκ³ 

PreviousSpring SingletonNextSpring Annotation

Last updated 4 years ago

Was this helpful?

κΉ€μ˜ν•œ μŠ€ν”„λ§ 핡심 원리 - 기본편