Maven will help us to available all required jar files during compile and run time. And build the application if some jar are missing it will automatically download the required jar from remote and places in local and build the application without fail.
mvnw this maven wrapper file help to download the maven if waven was not found in machine
Spring Boot actuator
Actuator are used to monitor the endpoints and manage application by adding spring-boot-starter-actuator dependency in the pom file and security purpose add spring-boot-starter-security
Example of actuator
/actuator/health to check status of spring boot application.
/actuator/info used get information of application
By adding following in the application.properties
manage.endpoints.web.exposure.include=health,info
manage.info.env.enable=true
info.app.name=some text
Info app.version=1.0
To use all actuator endpoints add management.endpoints.web.exposure.include=*
To Remo actuator endpoints add
management.endpoints.web.exposure.exclude=*
Or use comma instead *
Security for the actuator
To override existing username and password for the actuator configurations use following
spring.security.user.name=some name
spring.security.user.password= some password
By default password is generated by the sping we we start application to override use above command
Add more actuator list
Injecting custom application properties
name1.name2= name
This can be injected by value annotations @Value
For example
@Value("${name1.name2}")
private String naming
Now name is injected to naming string
Comman application properties
Hibernate
A framework used to save java object in the database.
Hibernate is the default implementation of JPA.
EntityManager is main component for creating queries and so on.
EntityManager is from Jakarta persistence APA (JPA)
Retrieving data from the database
Student obj=entityManager.find(Student.class,I'd);
Application properties
Command to turn off the spring boot banner which is displayed when we started running application include following cmd in application properties
> spring.main.banner-mode=off
Cmd to reduce logging display on log tab by
> spring.level.root=warn
Things in Java
In java default no argument constructor is created by java if argument constructor is not created. If argument constructor is created manually then no argument constructor is not created by java has to define manually.
Java annotations
@Repository
Annotation for repositories used to scan components and translates JDBC exception.
@Transactional
Transational annotation is used when we perform any update operation.
Data access object in spring boot
save
findById
findAll
findByLastName
update
delete
deleteAll