日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 前端技术 > javascript >内容正文

javascript

java的自动装配是什么意思_java – 什么时候在Spring中使用自动装配

發(fā)布時(shí)間:2024/4/13 javascript 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java的自动装配是什么意思_java – 什么时候在Spring中使用自动装配 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

我正在讀書(shū)

Pro Spring 3.它有一個(gè)段落,真的讓我困惑。這一段關(guān)于Spring的自動(dòng)裝配。這是一個(gè)摘錄:

In most cases, the answer to the question of whether you should use

autowiring is definitely “no!” Autowiring can save you time in small

applications, but in many cases, it leads to bad practices and is

inflexible in large applications. Using byName seems like a good

idea, but it may lead you to give your classes artificial property

names so that you can take advantage of the autowiring functionality.

The whole idea behind Spring is that you can create your classes how

you like and have Spring work for you, not the other way around …

… For any nontrivial application, steer clear of autowiring at all

costs.

我一直在我創(chuàng)建的應(yīng)用程序中使用@Autowired標(biāo)簽。有人可以解釋什么是錯(cuò)誤的,我應(yīng)該用什么呢?

關(guān)于我現(xiàn)在處理大多數(shù)事情的一個(gè)迷你例子是:

@Service("snippetService")

public class SnippetService {

@Autowired

private TestService testService;

public Snippet getSnippet() {

return testService.getSnippet();

}

}

是否使用自動(dòng)裝配像這樣“錯(cuò)了”還是我錯(cuò)過(guò)了什么?

總結(jié)

以上是生活随笔為你收集整理的java的自动装配是什么意思_java – 什么时候在Spring中使用自动装配的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。