The prefix "tx" for element "tx:advice" is not bound 錯誤的說明

在開發Spring的過程中,有時會出現Eclipse不能識別標籤。

1.提示出現以下錯誤:
[img]http://dl.iteye.com/upload/attachment/469466/5f85137c-d28e-322e-945b-a26092040061.png[/img]
這個錯誤的原因是:[color=red][b]我們在定義申明AOP的時候,沒有加載schema[/b][/color]。

2.Spring的配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
[color=red]xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"[/color]
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
[color=red]http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd[/color]">
紅色標記的內容是需要添加的內容,添加之後Eclipse就能夠識別<tx:advice/>,<aop:config/>
標籤了。
3.解釋一下(* com.evan.crm.service.*.*(..))中幾個通配符的含義:

第一個 * —— 通配 任意返回值類型
第二個 * —— 通配 包com.evan.crm.service下的任意class
第三個 * —— 通配 包com.evan.crm.service下的任意class的任意方法
第四個 .. —— 通配 方法可以有0個或多個參數

所以(* com.evan.crm.service.*.*(..))匹配:包com.evan.crm.service下的任意class的具有任意返回值類型、任意數目參數和任意名稱的方法。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章