码迷,mamicode.com
首页 > 编程语言 > 详细

1spring

时间:2018-07-27 13:16:23      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:XML   service   font   java   public   rem   epo   app   tle   

最新开发包及文档下载地址
spring-framework-4.0.6.RELEASE-dist.zip 

核心jar 包:


src/beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"> 
    <bean class="com.java1234.test.HelloWorld" id="helloWorld"/>
</beans>

package com.java1234.test;
public class HelloWorld {
 public void say(){
  System.out.println("Spring4大爷你好!");
 }
}

package com.java1234.service;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.java1234.test.HelloWorld;
public class Test {

 public static void main(String[] args) {
  ApplicationContext ac=new ClassPathXmlApplicationContext("beans.xml");
  HelloWorld helloWorld=(HelloWorld)ac.getBean("helloWorld");
  helloWorld.say();
 }
}





1spring

标签:XML   service   font   java   public   rem   epo   app   tle   

原文地址:https://www.cnblogs.com/linux777/p/9376890.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!