JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » 違規輔導區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
話題被移動
該話題已被移動 - browser , 2006-03-24 00:04
如果您尚不清楚該話題被移動的原因,請參考論壇規則以及本版公告或者聯系本版版主。
本主題所含的標籤
無標籤
作者 編寫spring入門程序出錯
unser





發文: 26
積分: 0
於 2006-03-23 23:49 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
http://www.javajia.com/modules.php?op=modload&name=News&file=article&sid=927

我是按照這里面進行編寫的,但出現以下錯誤:
The constructor XmlBeanFactory(InputStream) is undefined

我是用Eclipse構建工程,再導入Spring的,目錄如下:

RunTest
-SpringTest.java
SpringBean
-HelloBean.java
bean.xml

代碼如下:
package RunTest;

import SpringBean.HelloBean;

import java.io.*;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;

public class SpringTest {
  public static void main(String[] args) throws IOException {
    InputStream is = new FileInputStream("bean.xml");
    BeanFactory bf = new XmlBeanFactory(is);
    
    HelloBean hb = (HelloBean)bf.getBean("HelloBean");
    System.out.println(hb.getHelloworld());
  }
}


package SpringBean;

public class HelloBean {
  private String helloworld = "Hello World!";

  public String getHelloworld() {
    return helloworld;
  }

  public void setHelloworld(String helloworld) {
    this.helloworld = helloworld;
  }
}


<?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="HelloBean" class="SpringBean.HelloBean">
    <property name="helloworld">
      <value>Hello,Rain!</value>
    </property>
  </bean>
</beans>


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
883 編寫spring入門程序出錯 unser 1369 2006-03-23 23:49
» JWorld@TW »  違規輔導區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8