productDao类中的save方法一定要static化?否则service里面报错误
productDao类中的save方法一定要static化? 代码如下:
package com.vae.dao;
import com.vae.entity.Product;
public class ProductDao {
public static void save(Product product){
System.out.println("Dao中的方法被执行");
}
}
package com.vae.service;
import com.vae.dao.ProductDao;
import com.vae.entity.Product;
public class ProductService {
private ProductDao productDao;
public void setProductDao(ProductDao productDao) {
this.productDao = productDao;
}
public void save(Product product){
System.out.println("Service中的方法被执行");
ProductDao.save(product);
}
}