Let us create a basic CRUD operation example using Spring Boot for better understanding.
There is no specific rule to prepare your project layout. But there are some best practices that will help us for better understanding.
This Class is treated as entry point of Spring Boot Application because this class must have a main method declared with @SpringBootApplication annotation.
Here @SpringBootApplication is used for three annotations those are:
We all know that Spring Boot helps in maintaining lesser configuration codes than other spring frameworks so, Spring Boot introduced application.properties file where we can write all the configurations in a single file. And the main advantage of using this application.properties file is it is Spring Boot’s default configuration file which is auto-detected without writing any spring based configurations. It should always be present inside “src/main/resources” directory.
We can mention various properties like Logging, AOP, Identity, Hibernate, JPA, JMX, Email, etc. In our application, we will only be mentioning hibernate properties and database connection properties.
For better understanding here is the example of application.properties file we used to create our application:
(note: Before adding hibernate configuration and database proiperties make sure you add respective database dependency to your pom.xml file)