• Spring阶段性学习总结(一)实现一个简单的HellowWorld


    记录一下自己Spring的学习历程

     1 package HelloWorld;
     2 
     3 public class HelloWorld {
     4 
     5     String name;
     6 
     7     public void setName(String name) {
     8         this.name = name;
     9     }
    10 
    11     public void hello() {
    12         System.out.println("helloWorld:" + name);
    13     }
    14 
    15     public HelloWorld() {
    16         System.out.println("我是构造方法!");
    17     }
    18 }
     1 package HelloWorld;
     2 
     3 import org.springframework.context.support.ClassPathXmlApplicationContext;
     4 
     5 public class Main {
     6     public static void main(String[] args) {
     7        
     8         ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("HelloWorld/applicationContext.xml");
     9         HelloWorld helloWorld = (HelloWorld) applicationContext.getBean("helloWorld");
    10         helloWorld.hello();
    11 
    12     }
    13 }
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <beans xmlns="http://www.springframework.org/schema/beans"
     3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4        xmlns:context="http://www.springframework.org/schema/context"
     5        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
     6 
     7     <bean id="helloWorld" class="HelloWorld.HelloWrold">
     8         <property name="name" value="张浩"></property>
     9     </bean>
    10 
    11 </beans>
  • 相关阅读:
    Python(调用函数、定义函数)
    Python(可变/不可变类型,list,tuple,dict,set)
    Python(变量、数据类型)
    java内存泄露
    java垃圾回收
    mac下安装mysql教程
    Http、Https请求工具类
    ThreadLocal内部机制及使用方法
    java单例模式详解
    (转)Java集合框架:HashMap
  • 原文地址:https://www.cnblogs.com/zhang188660586/p/11557037.html
Copyright © 2020-2023  润新知