[英]How can I use the simple class name in Spring beans?
How can I use 我该怎么用
<bean id="oneId" class="OneClass">
<property name="prop" ref="anotherBean">
</bean>
instead of 代替
<bean id="oneId" class="com.bla.bla.bla.OneClass">
<property name="prop" ref="anotherBean">
</bean>
? ?
Is there a possibility to import a package? 是否有可能导入包裹?
There are a lot of classes from the same package and I'd like to make the XML file more readable. 同一个包中有很多类,我想让XML文件更具可读性。
It appears that you cannot use the simple class name instead of the fully qualified class name, as this Stack Overflow article discusses (and qv the Spring documentation itself), unless your bean oneId
serves only as a parent for child beans. 看起来你不能使用简单的类名而不是完全限定的类名,因为这篇Stack Overflow文章讨论了(并且修改了Spring文档本身),除非你的bean
oneId
仅用作子bean的父类。
However, if you use annotations instead of the XML descriptor files, you can use the simple class name OneClass
and allow the import statement to handle the messiness of the package name qualifier. 但是,如果使用注释而不是XML描述符文件,则可以使用简单类名
OneClass
并允许import语句处理包名限定符的混乱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.