Spring注解和标签的比较说明

xml标签 注解 说明
xml的Spring约束头 @Configuration

xml约束头表明这是用于spring的的配置文件

@Configuration注解表情这是用于Spring的配置类

<import resource="例如.xml"/> @Import({Class数组}) <import resource="例如.xml"/> 向一个xml中引入另一个xml@Import({Class数组}) 向一个配置类中引入另一个配置类
<context:property-placeholder location="classpath:db.properties"/> @EnableConfigurationProperties({class类数组}) <context:property-placeholder location="classpath:db.properties"/> 向一个xml配置文件中引入一个properties配置文件@EnableConfigurationProperties({class类数组}) 向一个配置类中引入另一个properties配置类(会被@ConfigurationProperties注解标注)
properties拓展名并且是键值对的配置文件 @ConfigurationProperties(prefix="properties文件的前缀",ignoreUnknownFields=boolean类型) properties拓展名并且是键值对的配置文件
注解表示是一个properties配置类
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     

猜你喜欢

转载自www.cnblogs.com/kitor/p/11741528.html