自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MyEclipse開發(fā)Spring入門操作

開發(fā) 后端
MyEclipse開發(fā)Spring入門操作將向你介紹如何用MyEclipse開發(fā)工具實施開發(fā)。
MyEclipse開發(fā)Spring入門的操作是什么呢?那么開始我們的講解吧:

1. 新建普通 Java 項目 MySpringTest. 這個過程無需贅述了, 建議建項目的時候?qū)?src 目錄和 bin(或者classes)目錄分開, 另外提示你切換透視圖的時候一定要切換過去到 Java 透視圖, 此時默認(rèn)會在 Package Explorer 中選中剛才已經(jīng)建好的 Java Project, 但是背景為灰色.

2. 首先單擊一下左邊的 Package Explorer 中新建的 MySpringTest 項目來使其高亮選中, 接著點擊菜單項 MyEclipse -> Add Spring Capabilities..., 接著會彈出對話框 Add Spring Capabilities 提示你設(shè)置當(dāng)前項目的 Spring 屬性.

對話框的***頁可以選擇全部的 Spring 框架, 這是最保險的做法, 不過我們的例子只需要選中Spring 2.0 Core Libraries 就可以了. 點擊 "Next" 繼續(xù).

第二頁是 Add Spring bean configuration file. 保持默認(rèn)值不變就可以了. ***點擊 Finish.

3. Spring 的開發(fā)沒法自動生成 Bean, 這里大家只好手工來寫了, 也很簡單. 分別復(fù)制下面的三個代碼, 然后在 MyEclipse src 目錄上點擊右鍵后選擇菜單項 Paste 就可以生成 Java 類文件了.

  1. public interface Action {   
  2.     
  3.   public String execute(String str);   
  4.    
  5. }   
  6.  
  7. public class UpperAction implements Action {   
  8.     
  9.   private String message;   
  10.     
  11.   public String getMessage() {   
  12.    return message;   
  13.   }   
  14.    
  15.   public void setMessage(String string) {   
  16.     message = string;   
  17.   }   
  18.    
  19.   public String execute(String str) {   
  20.    return (getMessage() + str).toUpperCase();   
  21.   }   
  22. }  
  23.  
  24. import org.springframework.context.ApplicationContext;  
  25. import org.springframework.context.support.ClassPathXmlApplicationContext;  
  26.  
  27. public class TestAction {  
  28.  
  29.  public static void main(String[] args) {  
  30.   ApplicationContext ctx = new ClassPathXmlApplicationContext(  
  31.     "applicationContext.xml");  
  32.   Action bean = (Action) ctx.getBean("theAction");  
  33.   System.out.println(bean.execute("Rod"));  
  34.  }  

4. 雙擊左側(cè)在第2步生成的 applicationContext.xml, 然后選擇菜單項 Window -> Show View -> Other..., 在彈出的對話框中選擇 MyEclipse Enterprise Workbench 節(jié)點下的 Spring Beans 子節(jié)點打開視圖 Spring Beans. 此視圖講出現(xiàn)在主界面的右下側(cè).

5. 展開此視圖中的 MySpringTest 父節(jié)點, 并選中 src/applicationContext.xml 子節(jié)點, 在此節(jié)點上點擊右鍵并選擇彈出菜單項中的 New Bean 來打開 Create a new Spring bean 對話框, 并按照下圖輸入對應(yīng)的內(nèi)容.

Bean Id: [theAction]

Bean class: [UpperAction]

接下來請單擊一下 Tab 面板 Properties 并點擊其中的 Add... 按鈕, 在接下來彈出的 Property Wizard 對話框中按照下圖輸入/選擇內(nèi)容:

Name: [message]

Spring type: [value]

Type: [java.lang.String]

Value:[Hello_]

***點擊兩次 Finish 按鈕關(guān)閉所有向?qū)υ捒? 然后點擊菜單 File -> Save. 此時可以看到 applicationContext.xml 的內(nèi)容如下所示:

  1. xmlns="http://www.springframework.org/schema/beans" 
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  3. xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd">  
  4.  
  5. lazy-init="default" autowire="default" dependency-check="default">  
  6.  
  7. Hello_ 

然后雙擊 Package Explorer 下 MySpringTest/src/TestAction.java 打開源代碼, 然后點擊菜單 Run -> Run As -> 1. Java Application, 如果沒有錯誤的話將會出現(xiàn)如下的輸入, 您的***個 Hello Spring 運行成功了:

  1. log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).  
  2.  
  3. log4j:WARN Please initialize the log4j system properly.  
  4.  
  5. HELLO_ROD 

接著您就可以對著參考書繼續(xù)創(chuàng)建類, 修改 applicationContext.xml 做更多的練習(xí)了.

開發(fā)整合 Hibernate 的關(guān)鍵操作點截圖:

1. 在數(shù)據(jù)庫瀏覽器中選擇反向工程菜單;

MyEclipse開發(fā)圖1 

2. 對話框的選項說明

MyEclipse開發(fā)圖2 

MyEclipse開發(fā)Spring就介紹到這里,希望對你的操作有幫助。

【編輯推薦】

  1. MyEclipse 6.0解決連接Oracle 10g的問題淺析
  2. Myeclipse 6.0破解方法詳解
  3. MyEclipse6.5+Eclipse3.4的中文問題淺析
  4. MyEclipse6.5漢化之葵花寶典
  5. MyEclipse5.5+Eclipse3.2+Tomcat5.5配置淺析
責(zé)任編輯:仲衡 來源: BeanSoft
相關(guān)推薦

2009-07-14 16:55:32

MyEclipse S

2009-06-30 14:02:00

hibernate入門MyEclipse開發(fā)

2009-07-14 18:35:53

MyEclipse實用

2009-06-11 10:37:58

netbeans spMVC基礎(chǔ)

2009-07-15 11:04:02

MyEclipse F

2010-08-19 16:00:53

MyEclipse 8MyEclipse 8

2009-07-14 13:55:24

MyEclipse S

2009-06-11 14:52:20

EJB組件MyEclipse

2009-07-09 18:05:02

MyEclipse開發(fā)

2009-07-14 13:14:13

2009-06-26 17:34:29

Spring入門

2009-07-14 15:31:26

MyEclipse開發(fā)

2009-07-14 15:42:38

MyEclipse開發(fā)

2010-12-13 14:41:44

Android 2.3MyEclipse

2009-07-09 17:33:39

2009-07-14 14:48:37

MyEclipse開發(fā)

2011-02-28 13:34:51

SpringMVC

2010-05-20 12:31:37

MyEclipse6.

2009-07-14 16:07:46

MyEclipse開發(fā)

2009-07-14 16:40:31

MyEclipse開發(fā)
點贊
收藏

51CTO技術(shù)棧公眾號