spring框架中的名稱空間
理解1:
你連查都懶得查啊,xml名稱空間通俗的說就是xml裡有哪些節點、子節點、屬性,他們都叫什麼名字,可以有哪些值,預設值是什麼,是不是必須的,有了這個xml就規範了。
還有其他意義上的名稱空間,你要自己查哦
名稱空間是為了解決相同作用域下的命名問題。
在C、C++、C#等語言中,都有名稱空間的概念,這是為了防止不同人編寫類庫發生命名衝突而設計的,名稱空間可以使變數、函式名稱、類名稱作用在本空間內,而其他空間可以使用同樣的名稱。就好比不同的資料夾下可以有相同的檔名一樣,但在相同的資料夾下不能有重複的檔名,名稱空間就好比這個虛擬的資料夾。
Java中的“包”的概念與“名稱空間”相似,均可避免命名衝突,對訪問進行控制,但在底層機制上還有所不同,Java的包邏輯結構與物理結構的統一,即一個包對應於磁碟上的一個資料夾,不同包裡的物件名稱自然可以相同,而名稱空間在儲存時並沒有這樣一種資料夾的形式,並且Java裡包均是並列的,不存在包中再建立一個包的關係,而名稱空間可以巢狀。
和其它語言裡面的名稱空間一樣,都是用來避免名稱衝突的。
這樣重名的元素或屬性可以用不同的名稱空間來區分開來。
為了更好的解析程式碼,在文件中定義一個或多個可供選擇的名稱空間,都可以在jar包裡找到
理解2:
最近常有人問起,一些spring的多種名稱空間的配置及其作用,今天在這裡就介紹幾個給大家。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/taskhttp://www.springframework.org/schema/task/spring-task.xsd">
<!--預設為false,是java本身的代理方式。設為true 表示強制使用cglib代理 -->
<aop:aspectj-autoproxy proxy-target-class="true"/>
<!-- 啟動註解 -->
<context:component-scan base-package="com.xxx"/>
<!-- Spring註解配置定時任務 -->
<task:annotation-driven/>
<!-- Spring自動注入properties檔案 -->
<util:properties id="configProp" location="classpath:server.properties" ignore-resource-not-found="true"/>
很簡單,但是在spring專案中基本很實用,還有比如mvc的引入等
xmlns:mvc=”http://www.springframework.org/schema/mvc”
xsi:schemaLocation=”http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd”
相關文章
- Spring名稱空間解析Spring
- JavaScript 中的名稱空間JavaScript
- 名稱空間
- JAXB名稱空間及名稱空間字首處理
- 自研 PHP 框架 1.1_名稱空間PHP框架
- Python中名稱空間是什麼?名稱空間生命週期是多久?Python
- PHP 名稱空間PHP
- PHP名稱空間PHP
- vuex名稱空間Vue
- jQuery 名稱空間jQuery
- JavaScript 名稱空間JavaScript
- DIY 實現 ThinkPHP 核心框架(四)名稱空間PHP框架
- Python 的名稱空間Python
- python名稱空間Python
- C++名稱空間C++
- 更改模型名稱空間模型
- 全域性名稱空間
- C++ 名稱空間C++
- Python 名稱空間Python
- yaml檔案中在哪加名稱空間?YAML
- Objective-C 的名稱空間Object
- 名稱空間與巢狀命名中的處理巢狀
- PHP 核心特性 - 名稱空間PHP
- 使用名稱空間:基礎
- ros節點名稱空間ROS
- PHP名稱空間概念解析PHP
- JAXB玩轉名稱空間
- System.Web 名稱空間Web
- Spring IOC容器【p名稱空間注入屬性值 】Spring
- C#解決一個奇怪的,名稱空間“XXX”中不存在型別或名稱空間名稱“xxx”的問題C#型別
- php名稱空間的呼叫順序PHP
- jquery的事件名稱空間詳解jQuery事件
- c# MySqlConnection的名稱空間C#MySql
- C++名稱空間的使用 (轉)C++
- C++ 中名稱空間的 5 個常見用法C++
- swift中的名稱空間及動態載入類Swift
- 對於PHP中名稱空間概念的入門理解PHP
- PHP 獲取不帶名稱空間的類名PHP