第一個spring簡單的helloworld


spring 是一個開源的框架 也是輕量級框架

1、導入jar包 spring的版本 4.0

目錄: spring-framework-4.0.0.RELEASE-libs 下的jar  spring最基本的jar

2、spring必須依賴的日志jar

3、寫一個配置文件applicationContext.xml  如下

<?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.atguigu.spring.helloworld.HelloWorld" >

<property name="userName" value="spring"></property>
</bean>

</beans>

4、hellowworld的java類

 

5、main方法

 

spring的第一個helloworld的程序寫完了

 如果不用 spring 創建對象

HelloWorld hello = new HelloWorld();

賦值

hello.setName("spring");

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM