-
1.
创
建
Spring
项目
首先
创建一个简单的
spring
项目,我用的是
< br>MyEclipse10.
步骤如下:
1.1
新建
Java
项目(<
/p>
MySpring
)
不要忘了引入
spring
的
jar
文件
1.2
创建包(
fe
)
1.3
在包下面创建以下文件
代码如下:
package fe;
import xception;
import
ctory;
import ctoryAware;
import meAware;
import
ableBean;
import lizingBean;
import ationContext;
import
ationContextAware;
public
class PersonService implements
BeanNameAware,BeanFactoryAware,
ApplicationContextAware,InitializingBean,Dispo
sableBean{
public
PersonService(){
n(
函数调用
}
public String
getName() {
return name;
}
public void
setName(String name) {
n(
调用
= name;
}
private String name;
public void sayHi(){
n(
}
public void
setBeanName(String arg0) {
// TODO Auto-generated method stub
n(
调用
}
//
传
递
Bean
工厂
public void
setBeanFactory(BeanFactory arg0) throws
BeansException {
// TODO Auto-generated
method stub
n(<
/p>
arg0)
调
用
}
public void
setApplicationContext(ApplicationContext arg0)
throws BeansException {
// TODO Auto-generated
method stub
n(
text
arg0)
调用
}
public void
afterPropertiesSet() throws Exception {
// TODO Auto-
generated method stub
n(
}
//
通过注解的方法配置
init-
method
方法
//@PostConstruct
public void init(){
n(
我自己的
init()
方法。。。。
}
public void
destroy() throws Exception {
// TODO Auto-generated
method stub
n(
}
public void MyDestory(){
n(
自己的
des
方法。
}
}
package fe;
import xception;
import
stProcessor;
public class MyBeanPostProcessor
implements BeanPostProcessor {
public Object
postProcessAfterInitialization(Object arg0,
String arg1)
throws BeansException {
// TODO Auto-
generated method stub
n(
arg0, String
arg1)
//n(arg0+<
/p>
创建时间为
());
return arg0;
}
public Object
postProcessBeforeInitialization(Object arg0,
String arg1)
throws BeansException {
// TODO Auto-
generated method stub
n(
arg0, String
arg1)
return
arg0;
}
}
x
ml
version
=
encoding
=
?>
p>
<
beans
xmlns
=
xmlns:xs
i
=
xmlns:context
=
p>
t
xmlns:tx
=
xsi:schemaLocation
=
< br>eans
/schema/beans/spring-
beans-2.5.x
sd
/schema/context
/schema/context/spring-context-2
-
-
-
-
-
-
-
-
-
上一篇:船公司大全_船公司中英文对照
下一篇:货代专业术语