{{{ #!html
Spring Eclipse
Spring 3.1 + Eclipse 3.6
}}} [[PageOutline]] = eclipse 安裝套件 = 在Eclipse的套件中, == 安裝AJDT == {{{ #!text eclipse->Help->install new software->add->輸入Name: ajdt URL: http://download.eclipse.org/tools/ajdt/36/dev/update }}} 其中36指的是Eclipse Helios版本,如果用的是3.4版,請改為34 == 安裝SpreingIDE == {{{ #!text Name: SpringIDE URL: http://dist.springframework.org/release/IDE }}} = 建立 Spring 專案 = {{{ #!text file -> new -> project -> Spring => Spring Project : myFirstSpring }}} = 匯入函式庫 = {{{ #!text 右鍵點選 myFirstSpring -> properties -> Java Build Path => Libraries => add External Jars }}} 將 spring 資料夾內的jar 檔加入,<<重要>> 並且將 jakara-commons 的 logging.jar 匯入 (可使用hadoop/lib/ 內的 commons-*.jar) = 建立佈署檔 beans-config.xml = {{{ #!text 右鍵點選 myFirstSpring -> new -> others -> XML => XML File -> myFirstSpring , File name = beans-config.xml }}} = beans-config.xml = {{{ #!xml Hello! Waue! }}} = src/waue.org/HelloBean.java = {{{ #!java package waue.org; public class HelloBean { private String helloWord; public void setHelloWord(String helloWord) { this.helloWord = helloWord; } public String getHelloWord() { return helloWord; } } }}} = src/waue.org/SpringDemo.java = {{{ #!java package waue.org; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; public class SpringDemo { public static void main(String[] args) { Resource rs = new FileSystemResource("beans-config.xml"); BeanFactory factory = new XmlBeanFactory(rs); HelloBean hello = (HelloBean) factory.getBean("helloBean"); System.out.println(hello.getHelloWord()); } } }}} = 執行與結果 = 以下兩種執行方法皆可 * run -> "run aspectj/java application" * run -> "run java application" [[Image(3.png)]]