leisure

          JAVA - exceed,helloworld
          隨筆 - 50, 文章 - 0, 評(píng)論 - 11, 引用 - 0
          數(shù)據(jù)加載中……

          hello,spring3

          spring很早就更新了3.0版本,可是由于項(xiàng)目要求穩(wěn)定,卻一直沒(méi)有使用到,最近有個(gè)新項(xiàng)目,打算采用spring3了。

          項(xiàng)目整個(gè)結(jié)構(gòu)如下:


           1 <?xml version="1.0" encoding="UTF-8"?>
           2 <beans xmlns="http://www.springframework.org/schema/beans"
           3      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           4      xmlns:p="http://www.springframework.org/schema/p"
           5      xsi:schemaLocation="http://www.springframework.org/schema/beans
           6      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
           7      
           8     <bean id="dao" class="Dao"/>
           9     
          10 </beans>

          1 
          2 public class Dao {
          3     public void find() {
          4         System.out.println("dao: find()");
          5     }
          6 }
          7 

           1 import org.springframework.context.ApplicationContext;
           2 import org.springframework.context.support.ClassPathXmlApplicationContext;
           3 
           4 public class Client {
           5 
           6     public static void main(String[] args) {
           7         ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
           8         Dao dao = context.getBean(Dao.class);
           9         dao.find();
          10     }
          11 }
          12 

          posted on 2011-12-29 16:02 leisure 閱讀(218) 評(píng)論(0)  編輯  收藏 所屬分類: java

          主站蜘蛛池模板: 古交市| 灵丘县| 沅陵县| 栖霞市| 勃利县| 绥棱县| 柏乡县| 三亚市| 孟州市| 青铜峡市| 贵南县| 习水县| 兴安县| 东港市| 察隅县| 广宗县| 峨山| 大冶市| 贵定县| 易门县| 霍城县| 手游| 武乡县| 乌拉特后旗| 教育| 太和县| 峡江县| 福鼎市| 依安县| 高雄市| 兴城市| 连山| 大安市| 新营市| 竹山县| 太保市| 永和县| 福泉市| 甘孜| 房山区| 淮北市|