Java 中 Bean 和 Bean.xml 的联系?
黄舟
黄舟 2017-04-18 09:18:57
0
3
462

Java 新人,我在看 Spring 的框架,其实有点一头雾水,今天就找到一个关于 Bean 和 Bean.xml 的信息,貌似 bean.xml 是用来部署配置用的,而 Java Beans 其实是 J2EE 的内置标准 Class 都可以叫做 Bean,可以是组合啥的(貌似是一个 Class,也有可能是... jar 包?)。

那么问题就是, Bean.xml 和 Java Beans 到底是啥?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
Ty80

Bean.xml can also be springxxx.xml or config.xml... In short, it can be... XXX.xml. There is even no need for xml, and there is no problem if it is written directly in the class. The "Bean.xml" here is just the configuration file used by spring to configure.

As for Java beans, they are generally modified by public, that is, public classes. Then there is generally a parameterless constructor.

Above.

黄舟

JavaBean must meet the following conditions:

  • public modifies this class

  • Private member variables

  • Corresponding to the public get and set methods of private member variables

  • No parameter constructor

bean.xml refers to the way to configure beans, right? In fact, in spring, it is recommended to use annotations to configure beans

迷茫

You are referring to bean.xml是指用xml文件的方式配置bean吧?启动时载入此文件,按照配置将一个个bean(Java Beans)add to the container after instantiation.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template