Spring學習
webapplicationcontext
-----------------------------------=-
account user1 = new account
java賦值方法:
建構函式初始值
set
動態位元組碼asm reflect -
--------------------------------------
protected ---------------------------------------------
step 1: initialize spring factory or bean factory
step2:[@more@]
package com.test.spring;
import java.sql.Timestamp;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.StringUtils;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import com.test.hibernate.Account;
public class AccountTest {
static ApplicationContext context;
static String bizConfigLocations="application-context.xml";
public static void main(String[] args) {
//Step 1: initialize Spring Context (or Factory)
try {
context = new ClassPathXmlApplicationContext(new String[]{bizConfigLocations});
} catch (BeansException bex) {
bex.printStackTrace();
}
Account richard=(Account)context.getBean("richard");
Group grp=(Group)context.getBean("group1");
System.out.println(richard.getName());
System.out.println(grp.getManager().getId());
}
}
package com.test.hibernate;
public class Account {
private Integer id;
private String name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.test.spring;
import com.test.hibernate.Account;
public class Group {
private Account manager;
private String groupName;
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public Account getManager() {
return manager;
}
public void setManager(Account manager) {
this.manager = manager;
}
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/219138/viewspace-913304/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- spring boot學習Spring Boot
- Spring Cloud學習SpringCloud
- Spring Boot 學習Spring Boot
- Spring學習03Spring
- Spring Security學習Spring
- Spring MVC學習SpringMVC
- Spring Boot學習3:web篇(中)-Spring boot Rest學習Spring BootWebREST
- spring學習:spring原始碼_BeanDefinitionSpring原始碼Bean
- 【spring原始碼學習】spring的IOC容器之BeanFactoryPostProcessor介面學習Spring原始碼Bean
- 【spring原始碼學習】Spring的IOC容器之BeanPostProcessor介面學習Spring原始碼Bean
- spring學習筆記Spring筆記
- spring入門學習Spring
- Spring 學習筆記Spring筆記
- Spring mvc學習指南SpringMVC
- Spring 學習小結Spring
- spring Ioc 的學習Spring
- java spring 框架學習JavaSpring框架
- spring學習(轉載)Spring
- Spring Boot學習4:web篇(下)-Spring boot (Servlet,Jsp)學習Spring BootWebServletJS
- Spring 學習筆記(2) Spring BeanSpring筆記Bean
- Spring 學習筆記(3)Spring MVCSpring筆記MVC
- Spring Boot學習6:Spring Boot JDBCSpring BootJDBC
- 學習Spring 開發指南------Spring初探Spring
- Spring原始碼學習之:ClassLoader學習(2)Spring原始碼
- Spring原始碼學習之:ClassLoader學習(3)Spring原始碼
- Spring原始碼學習之:ClassLoader學習(4)Spring原始碼
- Spring Kafka深入學習分析SpringKafka
- (七) Spring學習總結Spring
- Spring Boot 學習目錄Spring Boot
- Spring學習記錄1Spring
- spring學習筆記(1)Spring筆記
- JAVA學習Spring整合MybatisJavaSpringMyBatis
- Spring 學習小記(九)Spring
- Spring學習筆記(一)Spring筆記
- Spring Boot 學習-基礎Spring Boot
- 學習Spring的體會Spring
- Spring Boot學習(一)——Spring Boot介紹Spring Boot
- 「Spring認證」如何開始學習Spring?Spring