沉睡森林@漂在北京

          本處文章除注明“轉(zhuǎn)載”外均為原創(chuàng),轉(zhuǎn)載請(qǐng)注明出處。

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            152 隨筆 :: 4 文章 :: 114 評(píng)論 :: 0 Trackbacks

                 /**

                  * @param args

                  */

                 public static void main(String[] args) {

                        // TODO Auto-generated method stub

                        String [] conf = new String[2];

                  conf[0]="applicationContext.xml";

                  conf[1]="dataAccessContext-jdbc.xml";

                  ApplicationContext appContext = new ClassPathXmlApplicationContext(conf);

          //        UserService us = (UserService) appContext.getBean("userService");

                  Customer cu = new Customer();

                  cu.setName("11");

                  cu.setAddress("aa");

                  cu.setEmail("ss");

                  cu.setPhone("ssss");

                  ICustomerService cs = (ICustomerService) appContext.getBean("customerService");

                 

                  cs.insert(cu);

                 

                  System.out.println("hello world!");

                 }

           

           

           

           

           

          package com.example.test;

           

          import org.junit.Test;

          import org.springframework.beans.factory.annotation.Autowired;

          import org.springframework.test.context.ContextConfiguration;

          import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;

           

          import com.example.domain.Customer;

          import com.example.service.ICustomerService;

           

          @ContextConfiguration(locations={"test-customerService.xml"})

          public class TestCustomerService extends

                 AbstractTransactionalJUnit4SpringContextTests {

              @Autowired

              private ICustomerService cs;

           

              @Test

              public void handleUserLogin() {

                 // User user = new User();

                 // user.setUserId(1);

                 // user.setLastIp("127.0.0.1");

                 // Date now = new Date();

                 // user.setLastVisit(now.getTime());

                 // userService.handleUserLogin(user);

           

                 Customer cu = new Customer();

                 cu.setName("11");

                 cu.setAddress("aa");

                 cu.setEmail("ss");

                 cu.setPhone("ssss");

           

                 cs.insert(cu);

           

                 System.out.println("hello world!");

              }

          }

          在同一目錄下放入文件:

          <?xml version="1.0" encoding="UTF-8"?>

          <beans xmlns="http://www.springframework.org/schema/beans"

              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              xsi:schemaLocation="http://www.springframework.org/schema/beans

          http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

           

          <!--  引入清單1定義的Spring配置文件 -->

              <import resource="classpath:/applicationContext.xml" />

              <import resource="classpath:/dataAccessContext-jdbc.xml" />

          </beans>

          posted on 2009-02-14 21:56 王總兵 閱讀(174) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 安达市| 土默特右旗| 拉萨市| 宁晋县| 会理县| 麟游县| 察隅县| 渝中区| 德格县| 湛江市| 兴和县| 梁河县| 岑巩县| 芜湖市| 鄂托克前旗| 鹤庆县| 冀州市| 田东县| 赤峰市| 淮北市| 潼南县| 沙田区| 乌拉特前旗| 盐亭县| 中西区| 肥乡县| 泊头市| 邳州市| 亳州市| 洮南市| 开封市| 杨浦区| 高安市| 汉寿县| 普宁市| 辰溪县| 曲阜市| 栖霞市| 曲阳县| 伊宁市| 花垣县|