久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <tfoot id='uKfB6'></tfoot>
        <legend id='uKfB6'><style id='uKfB6'><dir id='uKfB6'><q id='uKfB6'></q></dir></style></legend>
      1. <i id='uKfB6'><tr id='uKfB6'><dt id='uKfB6'><q id='uKfB6'><span id='uKfB6'><b id='uKfB6'><form id='uKfB6'><ins id='uKfB6'></ins><ul id='uKfB6'></ul><sub id='uKfB6'></sub></form><legend id='uKfB6'></legend><bdo id='uKfB6'><pre id='uKfB6'><center id='uKfB6'></center></pre></bdo></b><th id='uKfB6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='uKfB6'><tfoot id='uKfB6'></tfoot><dl id='uKfB6'><fieldset id='uKfB6'></fieldset></dl></div>

        <small id='uKfB6'></small><noframes id='uKfB6'>

          <bdo id='uKfB6'></bdo><ul id='uKfB6'></ul>

        XML 配置與基于注釋的配置

        Xml configuration versus Annotation based configuration(XML 配置與基于注釋的配置)

        <small id='CF3cF'></small><noframes id='CF3cF'>

          <tfoot id='CF3cF'></tfoot>
            <bdo id='CF3cF'></bdo><ul id='CF3cF'></ul>
              <legend id='CF3cF'><style id='CF3cF'><dir id='CF3cF'><q id='CF3cF'></q></dir></style></legend>
                  <tbody id='CF3cF'></tbody>
              • <i id='CF3cF'><tr id='CF3cF'><dt id='CF3cF'><q id='CF3cF'><span id='CF3cF'><b id='CF3cF'><form id='CF3cF'><ins id='CF3cF'></ins><ul id='CF3cF'></ul><sub id='CF3cF'></sub></form><legend id='CF3cF'></legend><bdo id='CF3cF'><pre id='CF3cF'><center id='CF3cF'></center></pre></bdo></b><th id='CF3cF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='CF3cF'><tfoot id='CF3cF'></tfoot><dl id='CF3cF'><fieldset id='CF3cF'></fieldset></dl></div>
                1. 本文介紹了XML 配置與基于注釋的配置的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在我最近從事的一些大型項目中,選擇其中一個(XML 或 Annotation)似乎變得越來越重要.隨著項目的增長,一致性對于可維護性非常重要.

                  In a few large projects i have been working on lately it seems to become increasingly important to choose one or the other (XML or Annotation). As projects grow, consistency is very important for maintainability.

                  我的問題是:基于 XML 的配置相對于基于注解的配置有哪些優勢?基于注解??的配置相對于基于 XML 的配置有哪些優勢?

                  My questions are: what are the advantages of XML-based configuration over Annotation-based configuration and what are the advantages of Annotation-based configuration over XML-based configuration?

                  推薦答案

                  注解有其用處,但它們并不是殺死 XML 配置的唯一靈丹妙藥.我建議將兩者混合使用!

                  Annotations have their use, but they are not the one silver bullet to kill XML configuration. I recommend mixing the two!

                  例如,如果使用 Spring,將 XML 用于應用程序的依賴注入部分是完全直觀的.這使代碼的依賴關系遠離將要使用它的代碼,相比之下,在需要依賴關系的代碼中使用某種注釋使代碼知道這種自動配置.

                  For instance, if using Spring, it is entirely intuitive to use XML for the dependency injection portion of your application. This gets the code's dependencies away from the code which will be using it, by contrast, using some sort of annotation in the code that needs the dependencies makes the code aware of this automatic configuration.

                  但是,與其使用 XML 進行事務管理,不如使用注釋將方法標記為事務性是非常有意義的,因為這是程序員可能希望知道的信息.但是一個接口將被注入為 SubtypeY 而不是 SubtypeX 不應該包含在類中,因為如果現在你想注入 SubtypeX,你必須更改你的代碼,而你之前有一個接口契約,所以使用 XML,您只需要更改 XML 映射,并且這樣做相當快速且輕松.

                  However, instead of using XML for transactional management, marking a method as transactional with an annotation makes perfect sense, since this is information a programmer would probably wish to know. But that an interface is going to be injected as a SubtypeY instead of a SubtypeX should not be included in the class, because if now you wish to inject SubtypeX, you have to change your code, whereas you had an interface contract before anyways, so with XML, you would just need to change the XML mappings and it is fairly quick and painless to do so.

                  我沒有使用過 JPA 注釋,所以我不知道它們有多好,但我認為將 bean 映射到 XML 中的數據庫也很好,因為對象不應該關心它的位置信息來自哪里,它應該只關心它可以用它的信息做什么.但是如果你喜歡 JPA(我沒有任何經驗),那就去吧.

                  I haven't used JPA annotations, so I don't know how good they are, but I would argue that leaving the mapping of beans to the database in XML is also good, as the object shouldn't care where its information came from, it should just care what it can do with its information. But if you like JPA (I don't have any expirience with it), by all means, go for it.

                  一般來說:如果注釋提供了功能并且本身充當注釋,并且沒有將代碼綁定到某些特定過程以便在沒有此注釋的情況下正常運行,那么請使用注釋.例如,標記為事務性的事務性方法不會殺死其操作邏輯,并且還可以用作良好的代碼級注釋.否則,此信息可能最好用 XML 表示,因為盡管它最終會影響代碼的運行方式,但不會改變代碼的主要功能,因此不屬于源文件.

                  In general: If an annotation provides functionality and acts as a comment in and of itself, and doesn't tie the code down to some specific process in order to function normally without this annotation, then go for annotations. For example, a transactional method marked as being transactional does not kill its operating logic, and serves as a good code-level comment as well. Otherwise, this information is probably best expressed as XML, because although it will eventually affect how the code operates, it won't change the main functionality of the code, and hence doesn't belong in the source files.

                  這篇關于XML 配置與基于注釋的配置的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲出現的每個字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉換 char 原語?)
                      <tbody id='EgCAB'></tbody>

                      <tfoot id='EgCAB'></tfoot>
                        • <bdo id='EgCAB'></bdo><ul id='EgCAB'></ul>
                        • <small id='EgCAB'></small><noframes id='EgCAB'>

                            <i id='EgCAB'><tr id='EgCAB'><dt id='EgCAB'><q id='EgCAB'><span id='EgCAB'><b id='EgCAB'><form id='EgCAB'><ins id='EgCAB'></ins><ul id='EgCAB'></ul><sub id='EgCAB'></sub></form><legend id='EgCAB'></legend><bdo id='EgCAB'><pre id='EgCAB'><center id='EgCAB'></center></pre></bdo></b><th id='EgCAB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='EgCAB'><tfoot id='EgCAB'></tfoot><dl id='EgCAB'><fieldset id='EgCAB'></fieldset></dl></div>
                            <legend id='EgCAB'><style id='EgCAB'><dir id='EgCAB'><q id='EgCAB'></q></dir></style></legend>
                          1. 主站蜘蛛池模板: www.色五月.com | 国外成人在线视频 | 国产ts人妖一区二区三区 | 国产亚洲精品综合一区 | 久久久精品久久久 | 91在线电影 | 国产成人小视频 | 男人的天堂视频网站 | 久久aⅴ乱码一区二区三区 91综合网 | 成人欧美一区二区三区在线播放 | 天天操天天射天天舔 | 成人午夜精品 | 亚洲精品综合一区二区 | 亚洲高清成人 | 久久精品一区二区三区四区 | 亚洲色图第一页 | 久久精品国产一区二区三区 | 久久综合欧美 | 国产精品视频www | 精品国产乱码久久久久久图片 | 精产国产伦理一二三区 | 免费观看的黄色网址 | 欧美四虎 | 正在播放国产精品 | 蜜桃精品在线 | 国产成人免费视频网站高清观看视频 | 国产高清美女一级a毛片久久w | 日本不卡一区 | 国产成人一区二区三区电影 | 九九国产在线观看 | 免费在线观看成人av | 久久专区| 国产二区av| 国产精品无码久久久久 | 亚洲精色 | 亚洲午夜久久久 | 一区二区三区在线 | 欧美日韩在线免费 | 久久精品亚洲精品 | 亚洲一区中文字幕 | 国产成人精品一区二区三区视频 |