spring 源码阅读入门
2016-09-10 18:43
531 查看
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项目;
![](https://img-blog.csdn.net/20160910182337420?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
解压后的spring包是如下的结构;
![](https://img-blog.csdn.net/20160910182434105?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
dist内是发布的包;
![](https://img-blog.csdn.net/20160910182443530?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
src内是对应的源码包;
![](https://img-blog.csdn.net/20160910182452562?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
项目属性导入全部的dist下的包,还有mysql-connector,commons-logging等;完成后如下图;
或者光导入项目用到的包也可;
![](https://img-blog.csdn.net/20160910182501843?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
点开一个导入的spring dist包,点击Source attachment,点击 Edit 按钮;
![](https://img-blog.csdn.net/20160910182514046?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
添加源码包的路径,即src下的包的路径;如下图;
发布包和源码包一个个对应的;
![](https://img-blog.csdn.net/20160910182524812?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
添加好之后如下;
![](https://img-blog.csdn.net/20160910182532809?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](https://img-blog.csdn.net/20160910182542453?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
完成上述后项目结构如下;
![](https://img-blog.csdn.net/20160910182552469?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
新建如下的包,类,文件;
![](https://img-blog.csdn.net/20160910182601313?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
代码;
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/beans http://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>
项目运行结果如下;
![](https://img-blog.csdn.net/20160910182628107?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
在
ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");//读取bean.xml中的内容
Person p = ctx.getBean("person",Person.class);//创建bean的引用对象
这两句下断点;然后开始debug;
停留在断点;
![](https://img-blog.csdn.net/20160910182640670?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
打F5,进入下一个函数;进到spring源码了;因为前面附着了spring源码包,对应的spring源码函数显示出来;
![](https://img-blog.csdn.net/20160910182708407?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
F5,下一个函数;
![](https://img-blog.csdn.net/20160910182727312?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
F5,下一个函数;
![](https://img-blog.csdn.net/20160910182738767?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
F5,下一个函数;
![](https://img-blog.csdn.net/20160910182748813?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
F5,下一个函数;
![](https://img-blog.csdn.net/20160910182758516?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
F5,下一个函数;
看到一列的函数调用,这个就是传说中的栈帧了;
![](https://img-blog.csdn.net/20160910182808297?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
如果进到没有附着源码的函数,则会提示Source not found,如上图;
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/beans http://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 Cloud介绍 Part2: Spring Cloud与微服务
- java对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 从源码安装Mysql/Percona 5.5
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- spring aop 无法代理父类方法 的解决方法
- Spring MVC过滤器-超类 GenericFilterBean
- c++11 + SDL2 + ffmpeg +OpenAL + java = Android播放器