最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Spring項目XML文件使用小結

 更新時間:2022年07月18日 09:38:57   作者:amcomputer  
這篇文章主要介紹了Spring項目XML文件使用常見介紹,主要包括項目pom文件,項目初始IOC容器及項目需要自動裝配的代碼詳解,本文通過實例代碼給大家介紹的非常詳細,需要的朋友可以參考下

1 項目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 項目初始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 項目需要自動裝配

```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>

增加的點:
1 xmlns:context="http://www.springframework.org/schema/context"等等頭文件

2 context:annotation-config/

4 項目需要注解

<?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"/>
<!--    注解驅動-->
    <context:annotation-config/>
</beans>

增加的點:

<context:component-scan base-package=“com.yang.pojo”/>

https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop

到此這篇關于Spring項目XML文件使用常見介紹的文章就介紹到這了,更多相關Spring項目XML文件使用內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Mybatis中如何設置sqlSession自動提交

    Mybatis中如何設置sqlSession自動提交

    在MyBatis中,默認情況下,獲取的SqlSession對象不會自動提交事務,這意味著在進行更新、刪除或插入等操作后,需要顯式調用commit方法來提交事務,但是,可以在獲取SqlSession時通過將openSession方法的參數(shù)設置為true
    2024-09-09
  • MyBatis全局配置文件詳解

    MyBatis全局配置文件詳解

    這篇文章主要介紹了mybatis 加載配置文件的方法,通過實例代碼給大家介紹了mybatis 加載配置文件的兩種方式,需要的朋友可以參考下
    2021-07-07
  • OpenFeign調用服務請求頭丟失Token的解決

    OpenFeign調用服務請求頭丟失Token的解決

    這篇文章主要介紹了OpenFeign調用服務請求頭丟失Token的解決方法,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-06-06
  • Spring Boot 數(shù)據(jù)校驗@Valid+統(tǒng)一異常處理的實現(xiàn)

    Spring Boot 數(shù)據(jù)校驗@Valid+統(tǒng)一異常處理的實現(xiàn)

    這篇文章主要介紹了Spring Boot 數(shù)據(jù)校驗@Valid+統(tǒng)一異常處理的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-04-04
  • Mybatis中foreach的使用詳解

    Mybatis中foreach的使用詳解

    Mybatis中foreach標簽的使用詳解,包括屬性說明、代碼示例和總結,感興趣的朋友跟隨小編一起看看吧
    2024-11-11
  • Springboot打包成jar發(fā)布的操作方法

    Springboot打包成jar發(fā)布的操作方法

    打包的方式有打包成jar包或者打包成war包發(fā)布,區(qū)別在于jar包內置了tomcat、netty等服務器,更改只需要修改pom.xml的坐標即可,war不內置服務器,需要上傳到服務器tomcat解壓后運行,本文分析Springboot打包成jar發(fā)布,感興趣的朋友一起看看吧
    2023-02-02
  • SpringBoot整合FastDFS中間件實現(xiàn)文件分布管理

    SpringBoot整合FastDFS中間件實現(xiàn)文件分布管理

    FastDFS是一個開源的輕量級分布式文件系統(tǒng),它對文件進行管理,功能包括:文件存儲、文件同步、文件上傳、文件下載等,解決了大容量存儲和負載均衡的問題,本文介紹了SpringBoot整合FastDFS中間件實現(xiàn)文件分布管理,需要的朋友可以參考下
    2024-08-08
  • java線程阻塞中斷與LockSupport使用介紹

    java線程阻塞中斷與LockSupport使用介紹

    本文將詳細介紹java線程阻塞中斷和LockSupport的使用,需要了解更多的朋友可以參考下
    2012-12-12
  • 帶你了解Java數(shù)據(jù)結構和算法之無權無向圖

    帶你了解Java數(shù)據(jù)結構和算法之無權無向圖

    這篇文章主要為大家介紹了Java數(shù)據(jù)結構和算法之無權無向圖?,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2022-01-01
  • Spring集成MyBatis?及Aop分頁的實現(xiàn)代碼

    Spring集成MyBatis?及Aop分頁的實現(xiàn)代碼

    這篇文章主要介紹了Spring集成MyBatis?及Aop分頁的實現(xiàn),本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-04-04

最新評論

碌曲县| 西城区| 凤凰县| 从江县| 自治县| 青岛市| 福泉市| 深水埗区| 镇沅| 澎湖县| 同德县| 潜山县| 永顺县| 渝中区| 高州市| 溧水县| 洮南市| 南漳县| 汕头市| 信丰县| 德保县| 阳山县| 南阳市| 肇州县| 新乡市| 汉源县| 临高县| 阜宁县| 玛沁县| 五大连池市| 建平县| 开原市| 四川省| 肥东县| 白玉县| 石台县| 德令哈市| 道孚县| 罗田县| 寻乌县| 余庆县|