欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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"为本地接口