zoukankan      html  css  js  c++  java
  • 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();
        }
    }
    

      

  • 相关阅读:
    关于http请求头的一些事
    关于http抓取字段的一些事
    多线程的一些事
    正则的一些事
    出现问题集及解决方案
    常见的正则
    Http常见状态码
    list&tuple简记
    函数式编程--高阶函数--sorted
    函数式编程--高阶函数--filter
  • 原文地址:https://www.cnblogs.com/nidegui/p/11068161.html
Copyright © 2011-2022 走看看