首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Spring学习-helloworld运用annotation配置

2012-10-16 
Spring学习-helloworld使用annotation配置1、使用annotation注解需要asm,cglib两个jar包,分别从http://forg

Spring学习-helloworld使用annotation配置

1、使用annotation注解需要asm,cglib两个jar包,分别从http://forge.ow2.org/project/showfiles.php?group_id=23&release_id=3334和http://cglib.sourceforge.net/下载并加入build path中

2、新建Spring3HelloWorld类,代码如下:

package spring3annotation;import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class Spring3HelloWorldConfigTest {/** * @param args */public static void main(String[] args) {// Initialize IoC ContainerAnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spring3HelloWorldConfig.class);System.out.println("Calling Bean method: sayHello()");// Retrieve the bean from ContainerSpring3HelloWorld myBean = (Spring3HelloWorld) context.getBean("spring3HelloWorld");myBean.sayHello();}}

?5、运行Spring3HelloWorldConfigTest

?6、英文教程http://www.roseindia.net/spring/spring3/configuration-spring.shtml

?7、asm是轻量级的字节码处理框架,日后再仔细研究?

热点排行