Spring
先來看一下Spring
下面用一個例子
先看一下服務器端的源代碼
public interface IBookService {
Book getById(String id);
}
public class Book {
public String name;
public String id;
public String author;
}
public class BookService implements IBookService {
public Book getById(String id) {
return BookStore
}
}
客戶端源代碼
public class BookQueryService {
private IBookService bookService;
public void setAccountService(IBookService bookService) {
this
}
public Book getBookById(String id) {
return bookService
}
}
//客戶端調用示例
public static void main(String[] args) {
ClassPathXmlApplicationContext context;
context = new ClassPathXmlApplicationContext(
BookQueryService bookQueryService = (BookQueryService) context
Book book = bookQueryService
}
[
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28950.html