ITPub博客

首页 > IT职业 > IT生活 > spring学习

spring学习

原创 IT生活 作者:abcbbc 时间:2007-05-04 17:15:34 0 删除 编辑
framework tech app ------------------------------------ 事务是一个典型的切面 spring.jar beansfactory applicationcontext
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;
}


}


http://www.springframework.org/dtd/spring-beans-2.0.dtd">


Beans









来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/219138/viewspace-913304/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: objectserializable
请登录后发表评论 登录
全部评论

注册时间:2011-09-07

  • 博文量
    56
  • 访问量
    699642