• spring实现helloWord


    第一步:添加架包

    第二步:写一个简单的实列

    package com.java.test;
    
    /**
     * @author nidegui
     * @create 2019-06-22 10:58
     */
    public class Helloworld {
    
        public void say(){
            System.out.println("nihao spring");
        }
    }
    

      

    第三步:用bean

    <?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.xsd">
    
    	<bean id="helloWorld" class="com.java.test.Helloworld"></bean>
    
      
    </beans>
    

      

    第四步:测试

    package com.java.test;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    /**
     * @author nidegui
     * @create 2019-06-22 11:00
     */
    public class Test {
        public static void main(String[] args) {
            ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml"); //获取bean
            Helloworld helloWorld = (Helloworld) ac.getBean("helloWorld");   //获取bean的名字
            helloWorld.say();
        }
    }
    

      

  • 相关阅读:
    Unity-WIKI 之 AllocationStats(内存分配)
    Unity-WIKI 之 DebugLine
    Unity-WIKI 之 DebugConsole
    Unity-WIKI 之 DrawArrow
    Unity 2D Sprite Lighting
    Unity 2D Touch Movement
    [Unity2D]2D Mobile Joystick
    DragRigidbody2D
    Finger Gestures 3.1
    2D Skeletal Animation Ready
  • 原文地址:https://www.cnblogs.com/nidegui/p/11068161.html
Copyright © 2020-2023  润新知