Reputation: 2110
i am studying spring framework i have some doubts to confirm:
I see that class objects are created as beans in xml file ... but my doubt is ... only pojo class beans need to be defined in xml for instatiation or all classes eg: my custom code class EncryptionUtil class that helps in encrypting data and so on custom logic classes also need to be instantiated using beans?This is my primary concern
what about cases like i use
JSONObject j = new JSONOBJect() (External libs);
ArrayList<String> a = new ArrayList<String>();
( java default object and collections) do these classes also need to have bean in xml?
i exactly dont know if spring ioc will instantiate each and every object or we need to instantiate only some objects also, in spring app does "new " keyword work for creating objects
What should we use to instantiate bean in spring mvc ? ie : like i used ApplicationContext in my spring app , should i get bean everywhere i need
will there be any problem if i use multiple annotations ie : of spring as well as hibernate on same class at same time? eg: something like this
@Id @GeneratedValue
@Column(name = "id")
private int id;
but if i want id to be autowired too ...
@Autowired @Id @GeneratedValue @Column(name = "id") private int id;
will this work?
Upvotes: 0
Views: 4220
Reputation: 4877
Upvotes: 3