关于@Service注解作用

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_42121746/article/details/102494040

@Service注解作用

1、 其getBean的默认名称是类名(头字母小写),可以@Service(“xxxx”)这样来指定,
2、其定义的bean默认是单例的,可以使用@Service(“beanName”) @Scope(“prototype”)来改变。
3、可以通过@PostConstruct和@PreDestroy指定初始化方法和销毁方法(方法名任意)

@Service("goodsService")
public class GoodsServiceImpl implements IGoodsService{
}

猜你喜欢

转载自blog.csdn.net/qq_42121746/article/details/102494040