leisure

          JAVA - exceed,helloworld
          隨筆 - 50, 文章 - 0, 評論 - 11, 引用 - 0
          數據加載中……

          hello,spring3

          spring很早就更新了3.0版本,可是由于項目要求穩定,卻一直沒有使用到,最近有個新項目,打算采用spring3了。

          項目整個結構如下:


           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 閱讀(216) 評論(0)  編輯  收藏 所屬分類: java

          主站蜘蛛池模板: 石景山区| 定远县| 云龙县| 客服| 沙雅县| 卢氏县| 大邑县| 蒲城县| 双鸭山市| 全州县| 紫阳县| 苍溪县| 泸西县| 和平县| 双鸭山市| 托克托县| 邢台市| 比如县| 孝昌县| 金溪县| 乌鲁木齐县| 天镇县| 石家庄市| 安康市| 鄂州市| 定州市| 河源市| 邢台县| 桂阳县| 仁布县| 平定县| 大悟县| 广汉市| 库尔勒市| 塔河县| 安义县| 金湖县| 东乡县| 蒙城县| 宜春市| 会东县|