Spring學習(2) 快速上手Spring

2021-10-08 23:45:32 字數 1648 閱讀 1070

匯入jar包

>

>

org.springframeworkgroupid

>

>

spring-webmvcartifactid

>

>

5.2.6.releaseversion

>

dependency

>

編寫**

編寫乙個hello實體類

public

class

hello

public

void

setstr

(string str)

@override

public string tostring()

';}}

編寫我們的spring檔案,這裡我們命名為beans.xml

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

xmlns

=""xmlns:xsi

=""xsi:schemalocation

="/spring-beans.xsd"

>

"hello"

class

="site.duing.pojo.hello"

>

name

="str"

value

="spring"

/>

bean

>

beans

>

測試

@test

public

void

test()

依賴注入 : 就是利用set方法來進行注入的

ioc是一種程式設計思想,由主動的程式設計變成被動的接收

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

xmlns

=""xmlns:xsi

=""xsi:schemalocation

="/spring-beans.xsd"

>

"mysqlimpl"

class

="site.duing.dao.userdaomysqlimpl"

/>

"oracleimpl"

class

="site.duing.dao.userdaooracleimpl"

/>

"serviceimpl"

class

="site.duing.serivce.userserviceimpl"

>

name

="userdao"

ref="oracleimpl"

/>

bean

>

beans

>

@test

public

void

test()

2 快速上手Spring

編寫spring程式 module spring 02 hellospring 匯入jar包 org.springframework spring webmvc 5.2.0.release 編寫 1 編寫hello實體類 package com.zzb.pojo public class hello...

3 快速上手Spring

匯入jar包 org.springframeworkgroupid spring webmvcartifactid 5.2.6.releaseversion dependency 編寫 編寫乙個hello實體類 public class hello public void setstr string...

Spring4 3入門 快速上手Spring

spring 框架是乙個集合了很多東西的框架,最核心最底層的就是ioc di.在這個基礎之上,有很多諸如 aoc,orm,webmvc,dao,context 之類的功能 容器 ioc di 控制反轉,依賴注入.就是你的類對應的物件不用你來 new,框架幫你 new,幫你 new 完了再放到你指定的...