Monday, March 9, 2015

Autowiring (Java Spring Annotations)

Hi,

Autowiring is a very useful function in Java annotation and Spring
http://java.dzone.com/articles/why-you-should-use-springs

So the key points to note when doing Autowire is:
- it cannot be a new object.

- you might need a setter function if you are wiring a particular variable.

- you can pass the autowired object by reference, but it will only be a read-only. hence if you are passing a DAO, you can only get read-only database access, and cannot write back to database.

- you are required to declare the autowired object in your application-context.xml (beans.xml)


More guides on autowiring:
http://www.tutorialspoint.com/spring/spring_autowired_annotation.htm

It is indeed difficult to understand, but damn useful to use.


No comments:

Post a Comment