300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > SpringBoot底层注解-@ImportResource导入Spring配置文件

SpringBoot底层注解-@ImportResource导入Spring配置文件

时间:2023-10-26 03:04:56

相关推荐

SpringBoot底层注解-@ImportResource导入Spring配置文件

======================beans.xml=========================<?xml version="1.0" encoding="UTF-8"?><beans xmlns="/schema/beans"xmlns:xsi="/2001/XMLSchema-instance"xmlns:context="/schema/context"xsi:schemaLocation="/schema/beans /schema/beans/spring-beans.xsd /schema/context /schema/context/spring-context.xsd"><bean id="haha" class="com.leon.boot.bean.User"><property name="name" value="zhangsan"></property><property name="age" value="18"></property></bean><bean id="hehe" class="com.leon.boot.bean.Pet"><property name="name" value="tomcat"></property></bean></beans>

@ImportResource("classpath:beans.xml")public class MyConfig {}======================测试=================boolean haha = run.containsBean("haha");boolean hehe = run.containsBean("hehe");System.out.println("haha:"+haha);//trueSystem.out.println("hehe:"+hehe);//true

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。