springboot读取xml配置
程序员文章站
2022-07-14 12:13:22
...
1、xml配置文件放在resources目录下
2、启动类加上注解@ImportResource(“classpath:testi.xml”)
3、使用spring容器取出bean
@Autowired
ApplicationContext appContext;
..main..{
appContext.getBean("workTestService")
}
注: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"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="workTestService" autowire="byType" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://218.111.111.111:10088/iss-iddddc/work/workIntfcService" />
<property name="serviceInterface" value="com.aabblili.iss.work.service.WorkIntfcService" />
</bean>
</beans>
name="serviceUrl"为http调用路径
name="serviceInterface"为本地接口
上一篇: 阻塞队列LinkedBlockingQueue原理简析
下一篇: Retrofit Call类简析
推荐阅读
-
SpringBoot配置发送Email的示例代码
-
c#读取XML多级子节点
-
详解ASP.NET Core实现强类型Configuration读取配置数据
-
springboot配置tomcat配置乱码(配置乱码原因和对应解决法)
-
C#从数据库读取数据到DataSet并保存到xml文件的方法
-
springboot介绍项目(springboot自动配置原理)
-
springboot介绍项目(springboot自动配置原理)
-
Android开发实现读取excel数据并保存为xml的方法
-
springboot2.0.3源码篇 - 自动配置的实现,发现也不是那么复杂
-
C#中如何使用 XmlReader 读取XML文件