春天-我项目中的每个班级应该都是豆吗? [英] spring - should every class in my project be a bean?

查看:35
本文介绍了春天-我项目中的每个班级应该都是豆吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,有几个@repositories,@Services和@Controllers

In my project there are several @repositories , @Services, @Controllers

我的问题是针对其他99%的班级:

My question is for the other 99% of the classes:

我也应该将它们声明为bean吗?

Should i declare them as beans as well?

优点\缺点?

谢谢..

推荐答案

Bean是将应用程序的较大组件连接在一起的一种方式.并非每个对象或类都是一个很大的组件.例如,考虑String类.所以答案是.

Beans are a way of wiring together the larger components of an application. Not every object or class is a large component. Consider the String class, for example. So the answer is no.

这篇关于春天-我项目中的每个班级应该都是豆吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆