本文共 2869 字,大约阅读时间需要 9 分钟。
1.创建Maven项目,项目名称springdemo35,如图所示
1.0.0 shequ springdemo13 0.0.1-SNAPSHOT 1.7 UTF-8 UTF-8 codelds https://code.lds.org/nexus/content/groups/main-repo junit junit 4.10 org.springframework spring-core 4.1.4.RELEASE org.springframework spring-context 4.1.4.RELEASE org.springframework spring-jdbc 4.1.4.RELEASE mysql mysql-connector-java 5.1.34
package com.mycompany.shequ.bean;public class Forum { private int fid; private String name; private int displayOrder; public int getDisplayOrder() { return displayOrder; } public void setDisplayOrder(int displayOrder) { this.displayOrder = displayOrder; } public int getFid() { return fid; } public void setFid(int fid) { this.fid = fid; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return "{fid=>"+this.fid+",name=>"+this.name+",displayOrder=>"+this.displayOrder+"}"; }}
package com.mycompany.shequ.test;import org.junit.Test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.mycompany.shequ.bean.Forum;public class AppTest { @Test public void beanTest(){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); Forum forum = (Forum)context.getBean("forumBean"); System.out.println(forum); }}
本文转自 素颜猪 51CTO博客,原文链接:http://blog.51cto.com/suyanzhu/1910041
转载地址:http://zwszx.baihongyu.com/