簡體   English   中英

在 Spring Boot 中,如果一個類用 @component 注釋,它的行為會像單例類嗎?

[英]In Spring boot if a class is annotated with @component will it behave like singleton class?

當我們用@service 和@component 注釋類時,有人能解釋一下幕后發生了什么嗎?

@Component 創建一個類的單例 bean,它是可自動檢測和自動配置的類路徑掃描。

默認情況下,spring ApplicationContextContainer 在此處將其視為單例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM