idea建立Spring專案實現IOC

2021-09-10 14:25:20 字數 905 閱讀 6444

ioc全稱: inverse of control, 控制反轉,ioc其實不是什麼技術,而是一種設計思想。

簡要的說就是:原本需要程式去主動new建立的物件,現在反轉過來交給spring的容器去建立。

建立乙個user類,忽略不重要的方法,並列印出user類的資訊,**如下:

public

class

user';

}}

配置bean.xml檔案 關聯user類的屬性並賦值,**如下圖。

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

xmlns

=""xmlns:xsi

=""xsi:schemalocation

=" /spring-beans.xsd"

>

"user"

class

="com.demo.user"

>

name

="name"

value

="李小立"

/>

name

="age"

value

="22"

/>

name

="***"

value

="男"

/>

bean

>

beans

>

最後在新建乙個演示類demomain

public

class

demomain

}

得到結果

Idea建立Spring專案

環境 win7 idea2018 classpath commons logging 1.2 spring framework 4.1.6.release step1建立工程 file new project 選擇spring專案,addtionnal lib and frameworks 選擇第乙...

IDEA建立jsp專案

參考文章 新建web專案 file new project,然後next next finish 新增web框架 配置tomcat 新增應用伺服器tomcat 啟動專案 tomcat預設8080埠被占用 之前做.net開發,iis上部署了幾個專案,8080埠被其中乙個專案使用,修改tomcat配置埠...

IDEA建立Spring Boot專案

先記錄下自己遇到的坑 1.修改預設埠 由於預設埠為8080,經常被占用,server.port 8099 2.熱部署的問題 有的人說直接修改pom.xml即可,如下 我們往 pom.xml 中新增乙個依賴就可以了 org.springframework.boot spring boot devtoo...