日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

spring 源码阅读入门

發布時間:2025/4/14 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 spring 源码阅读入门 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

spring和源碼3.0.5下載

http://download.csdn.net/download/haluoyimo/7752753

http://pan.baidu.com/s/1qYnK784


參考文章

http://www.cnblogs.com/xing901022/p/4178963.html


首先新建一個Java項目;



解壓后的spring包是如下的結構;


dist內是發布的包;


src內是對應的源碼包;


項目屬性導入全部的dist下的包,還有mysql-connector,commons-logging等;完成后如下圖;

或者光導入項目用到的包也可;



點開一個導入的spring dist包,點擊Source attachment,點擊 Edit 按鈕;



添加源碼包的路徑,即src下的包的路徑;如下圖;

發布包和源碼包一個個對應的;



添加好之后如下;





完成上述后項目結構如下;



新建如下的包,類,文件;


代碼;

Person.java

package com.test.bean;public class Person {private String name;private int age;public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public void info(){System.out.println("name:"+getName()+" age:"+getAge());}}
test.java

package testSpring;import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;import com.test.bean.Person;public class test {public static void main(String[] args){ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");//讀取bean.xml中的內容Person p = ctx.getBean("person",Person.class);//創建bean的引用對象p.info();} }
bean.xml

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://www.springframework.org/schema/beans"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd"><bean id="person" class="com.test.bean.Person"><property name="name" value="xingoo"/><property name="age" value="12"/></bean> </beans>
項目運行結果如下;


ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");//讀取bean.xml中的內容
Person p = ctx.getBean("person",Person.class);//創建bean的引用對象

這兩句下斷點;然后開始debug;


停留在斷點;



打F5,進入下一個函數;進到spring源碼了;因為前面附著了spring源碼包,對應的spring源碼函數顯示出來;



F5,下一個函數;


F5,下一個函數;


F5,下一個函數;


F5,下一個函數;


F5,下一個函數;

看到一列的函數調用,這個就是傳說中的棧幀了;


如果進到沒有附著源碼的函數,則會提示Source not found,如上圖;


總結

以上是生活随笔為你收集整理的spring 源码阅读入门的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。