一般都是把xml配置文件转换为@Bean的模式,如果非要使用xml配置文件,方式如下:
/** * 将配置文件引入springboot */ @Configuration @ImportResource(locations={"classpath:hps.xml"}) public class XMLConfiguration { }
配置文件如下:
<?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="cmfErrorCodeServiceImpl" class="com.shengpay.hpsplus.service.core.common.CmfErrorCodeServiceImpl"> <property name="configMap"> <map> <entry key="EXCEED_CARD_BIND_TIMES"> <set> <value>F1101</value> </set> </entry> <entry key="VALIDCODE_SEND_FAIL"> <set> <value>F1069</value> </set> </entry> <entry key="CMF_SYSTEM_ERROR"> <set> <value>0001</value> <value>0002</value> <value>9999</value> <value>E1001</value> <value>E1013</value> <value>E1006</value> </set> </entry> <entry key="CARD_TYPE_INCORRECT"> <set> <value>F1011</value> </set> </entry> <entry key="CARD_NO_INCORRECT"> <set> <value>F1012</value> <value>F1035</value> <value>F0304</value> <value>F1048</value> </set> </entry> <entry key="BANK_CARD_UNSIGN"> <set> <value>F1070</value> </set> </entry> <entry key="TRUE_NANME_INCORRECT"> <set> <value>F1013</value> </set> </entry> <entry key="CARD_EXPIRY_INCORRECT"> <set> <value>F1014</value> </set> </entry> <entry key="CVV2_INCORRECT"> <set> <value>F1015</value> </set> </entry> <entry key="ID_TYPE_INCORRECT"> <set> <value>F1016</value> </set> </entry> <entry key="ID_NO_INCORRECT"> <set> <value>F1017</value> </set> </entry> <entry key="MOBILE_INCORRECT"> <set> <value>F1018</value> </set> </entry> <entry key="CARD_STATUS_INVALID"> <set> <value>F1022</value> <value>F1023</value> <value>F1025</value> <value>F1026</value> <value>F1037</value> <value>F1038</value> <value>F0301</value> <value>F1037</value> <value>F0607</value> </set> </entry> <entry key="BLANCE_NO_ENOUTH"> <set> <value>F1036</value> </set> </entry> <entry key="AGREEMENT_EXIST"> <set> <value>F0606</value> </set> </entry> <entry key="CARD_IDENTITY_MISMATCH"> <set> <value>F1043</value> </set> </entry> <entry key="MOBILE_INCORRECT2"> <set> <value>F1046</value> </set> </entry> <entry key="ID_NO_OR_MOBILE_INCORRECT"> <set> <value>F1065</value> </set> </entry> <entry key="CARD_NO_ENOUGH_STATIS"> <set> <value>F0202</value> </set> </entry> <entry key="CARD_FUND_NUM_OVER"> <set> <value>F0205</value> </set> </entry> <entry key="SYSTEM_ERROR"> <set> <value>F0101</value> </set> </entry> <entry key="BANK_SYSTEM_ERROR"> <set> <value>F1100</value> <value>F1050</value> <value>F1051</value> <value>F1044</value> <value>F1030</value> <value>F0601</value> </set> </entry> <entry key="BANK_NOT_SUPPORT"> <set> <value>F1003</value> </set> </entry> <entry key="CARD_FUND_ERROR_NUM_OVER"> <set> <value>F1076</value> </set> </entry> <entry key="OTHER_CARD_ERROR"> <set> <value>F1073</value> </set> </entry> </map> </property> </bean> <!-- 返回码映射服务 --> <bean id="returnCodeService" class="com.shengpay.rcm.service.ReturnCodeZkService" init-method="init" destroy-method="destroy"> <property name="zkConnectString" value="${returncode.service.url}"/> </bean> </beans>