生活随笔
收集整理的這篇文章主要介紹了
Spring安装与入门
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. Spring組成
?
- Inversion of Control (IoC)
- Aspect Oriented Programming (AOP)
- Abstract Service
2. Spring下載
http://www.springsource.com/download/community?sid=1212680
3. Spring實例
| EricTest.java |
| package erictest;
import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext;
public class EricTest { ?? ?public static void main(String argv[]) { ??????? ApplicationContext ctx = new FileSystemXmlApplicationContext("src/ericspring.xml"); ??????? ShowMessage sm = (ShowMessage)ctx.getBean("ericBean"); ??????? sm.show(); ?? ?} }
|
| ShowMessage.java
|
| package erictest;
public class ShowMessage {
??? private String message;
??? public void setMessage(String message){ ?????????? this.message = message; ??? } ??? ??? public String getMessage(){ ?????????? return this.message; ??? }
??? public void show(){ ?????????? System.out.print("Spring Test Message: " + getMessage()); ??? } }
|
?
| ericspring.xml |
| package erictest;
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> ??? <bean id = "ericBean" class="erictest.ShowMessage"> ?????? <property name="message"> ?????????? <value>Says Hello Spring!</value> ?????? </property> ??? </bean> </beans> |
運行即可顯示結果
| Spring Test Message: Says Hello Spring! |
轉載于:https://www.cnblogs.com/ericsun/archive/2011/07/11/2103502.html
總結
以上是生活随笔為你收集整理的Spring安装与入门的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。