File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Spring bean name and annotations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring bean name and annotations" Watch "Spring bean name and annotations" New topic
Author

Spring bean name and annotations

Joe Chambers
Greenhorn

Joined: Jun 16, 2010
Posts: 1
We use a vendor package that accesses spring beans via the bean "name" as in <bean name="/proxy">...</bean>. As we upgrade to spring 3.0 we are trying to use annotation configuration instead of xml.

Since the bean name can include values that are not allowed in bean id's, is there a method for doing this in annotations i.e. Component, Repository...?

Thanks
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Joe Chambers wrote:We use a vendor package that accesses spring beans via the bean "name" as in <bean name="/proxy">...</bean>. As we upgrade to spring 3.0 we are trying to use annotation configuration instead of xml.

Since the bean name can include values that are not allowed in bean id's, is there a method for doing this in annotations i.e. Component, Repository...?

Thanks


Yes, you can put the name of the bean directly in the annotation

@Repository("MyBeanNameHere")

But in most cases when you are using annotations that are @Components, then you are also using @Autowired, so bean names at that point become not necessary.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring bean name and annotations