在理解“ Spring @Autowired用法”這個(gè)問(wèn)題之后,我想為彈簧接線的另一個(gè)選項(xiàng)(@Configuration類)創(chuàng)建一個(gè)完整的知識(shí)庫(kù)。假設(shè)我有一個(gè)看起來(lái)像這樣的spring XML文件:<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <import resource="another-application-context.xml"/> <bean id="someBean" class="stack.overflow.spring.configuration.SomeClassImpl"> <constructor-arg value="${some.interesting.property}" /> </bean> <bean id="anotherBean" class="stack.overflow.spring.configuration.AnotherClassImpl"> <constructor-arg ref="someBean"/> <constructor-arg ref="beanFromSomewhereElse"/> </bean></beans>我該如何使用@Configuration呢?它對(duì)代碼本身有影響嗎?
3 回答

牛魔王的故事
TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超3個(gè)贊
這是一個(gè)很好的論據(jù),我已經(jīng)聽(tīng)過(guò)幾次了。而且我嘗試進(jìn)行一些統(tǒng)計(jì)研究,在其中我找不到在jars / wars之外使用XML的任何應(yīng)用程序或系統(tǒng)。它的實(shí)際含義是您需要解壓縮jar并更改XML(我找不到找到它的人)或重建您的jar(這是我與之交談的所有人到目前為止所做的事情) 。因此,底線-盡管可能是一個(gè)相當(dāng)大的論點(diǎn),但在現(xiàn)實(shí)生活中通常并不重要。
添加回答
舉報(bào)
0/150
提交
取消