博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
spring学习
阅读量:2491 次
发布时间:2019-05-11

本文共 2295 字,大约阅读时间需要 7 分钟。

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;
}
}

<?xml version="1.0" encoding="GB2312"?>

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

Beans

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

转载于:http://blog.itpub.net/219138/viewspace-913304/

你可能感兴趣的文章
PCB设计技巧与注意事项
查看>>
linux进程之间通讯常用信号
查看>>
main函数带参数
查看>>
PCB布线技巧
查看>>
关于PCB设计中过孔能否打在焊盘上的两种观点
查看>>
PCB反推理念
查看>>
京东技术架构(一)构建亿级前端读服务
查看>>
php 解决json_encode中文UNICODE转码问题
查看>>
LNMP 安装 thinkcmf提示404not found
查看>>
PHP empty、isset、innull的区别
查看>>
apache+nginx 实现动静分离
查看>>
通过Navicat远程连接MySQL配置
查看>>
phpstorm开发工具的设置用法
查看>>
Linux 系统挂载数据盘
查看>>
Git基础(三)--常见错误及解决方案
查看>>
Git(四) - 分支管理
查看>>
PHP Curl发送数据
查看>>
HTTP协议
查看>>
HTTPS
查看>>
git add . git add -u git add -A区别
查看>>