• Spring 开发第一步


       经过今天上午的学习发现spring上手开发一个"hello world"真的非常简单。

    开发环境搭建:

    1、去spring官网下载spring-framework-3.2.11.RELEASE-dist.zip 。这里带dist的是二进制的jar包,不带dist的是源代码

    2、eclipse下新建一个java项目,把上面的包解压后的jar都引用到项目里去,还要再引入一个commons-logging.jar不然会报日志logging factory找不到的错误。

    运行《spring in action 3rd Edition》chapter 2中的例子:

    package com.springinaction.springidol;
    
    public interface Performer {
        void perform() throws PerformanceException;
    }
    package com.springinaction.springidol;
    
    public class Juggler implements Performer{
        private int bags = 3;
        public Juggler(){
            
        }
        public Juggler(int bags){
            this.bags = bags;
        }
        public void perform() throws PerformanceException{
            System.out.println("Juggling "+ this.bags + " bags.");
        }
    }
    <?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-3.0.xsd">
    <!-- Beans declararions go here -->
    <bean id="duke" class="com.springinaction.springidol.Juggler"></bean>
    </beans>

    ApplicationContext ctx = new ClassPathXmlApplicationContext("com/springinaction/springidol/spring-idol.xml");
    Performer performer = (Performer)ctx.getBean("duke");
    performer.perform();

    运行结果:Juggling 3 bags.

  • 相关阅读:
    Libcurl
    Inno Setup教程
    APICloud平台的融云2.0集成
    关于mysql建立索引 复合索引 索引类型
    linux恢复误删除文件-extundelete
    OpenStack QA
    Android之应用程序怎样调用支付宝接口
    NYOJ 22 素数求和问题
    Mycat(5):聊天消息表数据库按月分表实践,平滑扩展
    opencv对图像进行边缘及角点检測
  • 原文地址:https://www.cnblogs.com/lyhero11/p/4050142.html
Copyright © 2020-2023  润新知