为了账号安全,请及时绑定邮箱和手机立即绑定

了解spring @Configuration类

了解spring @Configuration类

杨__羊羊 2019-12-07 15:43:06
在理解“ 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(这是我与之交谈的所有人到目前为止所做的事情) 。因此,底线-尽管可能是一个相当大的论点,但在现实生活中通常并不重要。 

查看完整回答
反对 回复 2019-12-07
  • 3 回答
  • 0 关注
  • 495 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信