在理解“ Spring @Autowired用法”這個問題之后,我想為彈簧接線的另一個選項(@Configuration類)創建一個完整的知識庫。假設我有一個看起來像這樣的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呢?它對代碼本身有影響嗎?
3 回答

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