關於springboot的學習筆記

1.springboot中如何註解方式注入一個map<string,object>?java

    查了一天,沒有查到經過註解的解決方法,不少只是簡單的properties的解決方法,沒有看到知足本身需求的,所以註解方式行不通;spring

 經過引入外置的xml配置文件,使用@ImportResource註解,在須要list的地方使用@Resource方法引入list;spring-mvc

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:oxm="http://www.springframework.org/schema/oxm" 
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

<util:list id="controllerHandlers">
		<bean class="tk.mybatis.springboot.controller.handler.APPControllerHandler" />
		<bean class="tk.mybatis.springboot.controller.handler.SeriesTranHandler" />
	</util:list>
</beans>

  在文件命名上,此處有坑:不能把xml文件名叫做application.xml,若是你已經有了application.yml文件springboot

不然會有文檔根元素 "beans" 必須匹配 DOCTYPE 根 "null"的錯誤提示。mybatis

Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 107; 文檔根元素 "beans" 必須匹配 DOCTYPE 根 "null"。
相關文章
相關標籤/搜索