1、

@ImportResource(locations = {"classpath:beantest.xml"})标注到启动类上,从类路径下加载xml文件,通过Application.getbean获取xml配置对象

一开始写错了// @PropertySource(value = { "class:beantest.xml" })

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
@ImportResource(locations = {"classpath:beantest.xml"})
@SpringBootApplication
public class Demo2Application {
// @PropertySource(value = { "class:beantest.xml" })
public static void main(String[] args) {
SpringApplication.run(Demo2Application.class, args);
} }

  bean文件

<?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.xsd"> <bean id="mao" class="com.example.demo.Maomao">
<property name="name" value="maomaomiaomiao"></property>
</bean> </beans>

  

最新文章

  1. gmc银联接口开发demo
  2. POJ3468 A Simple Problem with Integers
  3. php验证码无法显示的原因
  4. 【原】数据库SQL语句入门
  5. 初步学习nodejs,业余用node写个一个自动创建目录和文件的小脚本,希望对需要的人有所帮助
  6. bootstrap-modal.js 居中问题
  7. spring_boot_pay支付宝,微信,银联支付详细代码案例
  8. Java读写Excel之POI超入门(转)
  9. ArcEngine ILabelEngineLayerProperties Expression 添加常量
  10. Redis protected-mode属性解读
  11. 决策树算法原理(ID3,C4.5)
  12. IDEA整合Junit测试框架
  13. webpack的版本进化史
  14. 怎样将M4A音频格式转换成MP3格式
  15. gulp和webpack的区别
  16. linux修改文件所有者和文件所在组 【转载】
  17. 去中心化存储的QoS是什么?
  18. django ---- models继承
  19. Netty系列之Netty线程模型
  20. Python3.x与Python2.x的差异用法

热门文章

  1. Python网络爬虫入门实战(爬取最近7天的天气以及最高/最低气温)
  2. FPGA之驱动sdram控制兼容性移植实验
  3. 为什么JDK动态代理中要求目标类实现的接口数量不能超过65535个
  4. 【Web技术】295- 重新复习 Unicode 和 UTF-8
  5. 深入探索Java设计模式(二)之策略模式
  6. 【Maven】plugin使用学习
  7. python学习-for
  8. Linux系统基础知识
  9. tinymce插件preview改造增加全屏按钮
  10. C# List集合 GroupBy分组