沉睡森林@漂在北京

          本處文章除注明“轉(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 王總兵 閱讀(177) 評(píng)論(0)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 重庆市| 无极县| 定州市| 馆陶县| 南投县| 沅江市| 泰和县| 乐都县| 呼图壁县| 丹江口市| 南康市| 色达县| 芦山县| 嘉荫县| 拜泉县| 安远县| 广德县| 正镶白旗| 禹城市| 江永县| 安阳市| 喀喇沁旗| 遂昌县| 唐山市| 若羌县| 嘉禾县| 灵寿县| 深州市| 会东县| 辉南县| 元阳县| 满城县| 清镇市| 西城区| 南平市| 德江县| 车险| 清苑县| 招远市| 寻乌县| 贺州市|