Spring的IOC註解開發

2021-09-02 11:43:32 字數 881 閱讀 4879

約束

<?xml version="1.0" encoding="utf-8"?>

xmlns

=""xmlns:xsi

=""xmlns:context

=""xsi:schemalocation="

/spring-beans.xsd

/spring-context.xsd"

>

beans

>

<

context:component-scan

base-package="

">

context:component-scan

>

@conponent

(value=

"usedao"

)//相當於配置了

public

class

userdaoimpl

implements

userdao

}

6.1@conponent :元件

6.2 屬性注入的註解

@autoware:設定物件型別的屬性的值,但是按照型別完成注入

@resource:完成物件型別屬性注入,按照名稱完成

6.3 bean的其他註解

@predestroy:銷毀

bean作用範圍的註解

Spring註解開發

spring註解開發 dao層用的註解 repository service層的註解 service controller表現層的註解 controller 以上的三個註解都是用 componment新增三個衍生的註解 屬性依賴注入 value的屬性注入 value wwtmy love 注入的是屬...

spring註解開發

第一步,設定xml約束檔案 第一步,設定xml約束檔案 xmlns xsi xmlns context xsi schemalocation spring beans.xsd spring context.xsd 第二步,定義bean 除了 component外,spring提供了3個功能基本和 c...

Spring註解開發

在spring4之後,要使用註解開發,但是必須保證aop的包存在 使用註解必須保證匯入context約束增加註解的支援 xmlns xmlns xsi xmlns context xsi schemalocation spring beans.xsd spring context.xsd conte...