Below are some commonly used configurations in spring :-
These are only some common configurations that we provide in spring applications. As you keep reading further and creating more programs, you will understand these configurations more deeply...!!
Spring provides three main ways for configurations :-
1. XML-based Configuration
2. Java-based Configuration
3. Annotations-based Configuration
<bean class="in.sp.beans.Student" id="stdId">
<property name="name" value="Deepak" />
<property name="rollno" value="101" />
<property name="emailid" value="deepak@gmail.com" />
</bean>
In this configuration, we are creating one Student Bean Object and setting the values in properties.
@Configuration
public class AppConfig
{
@Bean
public Student stdId()
{
return new Student("Deepak");
}
}
In this configuration, we create creating one Student Bean Object and setting the values using constructor.
@Component
public class Student
{
private String name = "Deepak";
}
//-----------
@Autowired
private Student student;
Your feedback helps us grow! If there's anything we can fix or improve, please let us know.
Weโre here to make our tutorials better based on your thoughts and suggestions.