Spring項(xiàng)目XML文件使用小結(jié)
1 項(xiàng)目pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.yang</groupId> <artifactId>spring-study</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <modules> <module>spring-01-ioc1</module> <module>spring-02-hellpspring</module> <module>spring-04-di</module> <module>spring-06-autowired</module> <module>spring-07-annotation</module> </modules> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.1.4.RELEASE</version> </dependency> </dependencies> </project> ···
2 項(xiàng)目初始IOC容器
```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" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- more bean definitions go here --> </beans> ···
3 項(xiàng)目需要自動(dòng)裝配
```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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"> <context:annotation-config/> <bean id="dog" class="com.yang.pojo.Dog"></bean> <bean id="cat" class="com.yang.pojo.Cat"></bean> <bean id = "people" class="com.yang.pojo.People"> <property name="cat" ref="cat"/> <property name="dog" ref="dog"/> <property name="name" value="張3"/> </bean> </beans>
增加的點(diǎn):
1 xmlns:context="http://www.springframework.org/schema/context"等等頭文件
2 context:annotation-config/
4 項(xiàng)目需要注解
<?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:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 指定要掃描的包,包下面的注解才能夠生效--> <context:component-scan base-package="com.yang.pojo"/> <!-- 注解驅(qū)動(dòng)--> <context:annotation-config/> </beans>
增加的點(diǎn):
<context:component-scan base-package=“com.yang.pojo”/>
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
到此這篇關(guān)于Spring項(xiàng)目XML文件使用常見(jiàn)介紹的文章就介紹到這了,更多相關(guān)Spring項(xiàng)目XML文件使用內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
springboot反爬蟲組件kk-anti-reptile的使用方法
這篇文章主要介紹了springboot反爬蟲組件kk-anti-reptile的使用方法,幫助大家更好的利用spring boot反爬蟲,保護(hù)網(wǎng)站安全,感興趣的朋友可以了解下2021-01-01Java和Python現(xiàn)在都挺火,我應(yīng)該怎么選?
這篇文章主要介紹了Java和Python現(xiàn)在都挺火,我應(yīng)該怎么選?本文通過(guò)全面分析給大家做個(gè)參考,需要的朋友可以參考下2020-07-07Java線程間協(xié)作wait、notify和notifyAll詳解
這篇文章主要介紹了Java線程間協(xié)作wait、notify和notifyAll詳解,在 Java 中可以用 wait、notify 和 notifyAll 來(lái)實(shí)現(xiàn)線程間的通信,盡管關(guān)于wait和notify的概念很基礎(chǔ),它們也都是Object類的函數(shù),但用它們來(lái)寫代碼卻并不簡(jiǎn)單,,需要的朋友可以參考下2023-10-10Java數(shù)據(jù)導(dǎo)出功能之導(dǎo)出Excel文件實(shí)例
這篇文章主要介紹了Java數(shù)據(jù)導(dǎo)出功能之導(dǎo)出Excel文件實(shí)例,本文給出了jar包的下載地址,并給出了導(dǎo)出Excel文件代碼實(shí)例,需要的朋友可以參考下2015-06-06Spring中ApplicationEvent事件機(jī)制源碼詳解
這篇文章主要介紹了Spring中ApplicationEvent事件機(jī)制源碼詳解,Spring中與事件有關(guān)的接口和類主要包括ApplicationEvent、ApplicationListener,下面來(lái)看一下Spring中事件的具體應(yīng)用,需要的朋友可以參考下2023-09-09微信開發(fā)準(zhǔn)備第二步 springmvc mybatis項(xiàng)目結(jié)構(gòu)搭建
這篇文章主要為大家詳細(xì)介紹了微信開發(fā)準(zhǔn)備第二步,springmvc和mybatis項(xiàng)目結(jié)構(gòu)的搭建,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04Elasticsearch算分優(yōu)化方案之rescore_query示例詳解
這篇文章主要為大家介紹了Elasticsearch算分優(yōu)化方案之rescore_query示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08maven引入kabeja依賴的實(shí)現(xiàn)步驟
本文主要介紹了maven引入kabeja依賴的實(shí)現(xiàn)步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-09-09java從字符串中提取數(shù)字的簡(jiǎn)單實(shí)例
下面小編就為大家?guī)?lái)一篇java從字符串中提取數(shù)字的簡(jiǎn)單實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-10-10