Spring is a very popular Java-based framework. It is used for building web applications and various enterprise level applications. Spring framework provides a wide variety of features addressing modren business needs. We can configure beans in a Spring application by various ways like XML, annotations and JavaConfig. As the number of features incresed, the Spring framework got complexer and complexer. It became very tedious and error prone to manage these Spring applications.
Spring Boot is not intended to replace Spring, but to make working with it faster and easier.
So to overcome all these problems, Spring boot came into existence.
It will do everything automatically for us and even allows us to override the defualts if you want to do so.
springboot-starter-web is used by default as it pulls out all the spring-data-jpa libraries at once. It also adds Hibernate libraries because most of the web and enterprise applications use Hibernate as JPA implementation.
It also configures the most cmmonly registered beans like Dispatcher Servlet, resource Handlers etc. with sensible defaults, so that these can be used without making any changes. If we have any in memory database like H2 or derby , then our Spring boot application automatically create an in- memory datasource and register the important components like EntityManagerFactory, TransactionManager , so that they can be easily used.
Most important use of using Spring boot is that by just adding an annotation @SpringApplication on a class having main methos and running that class by providing the required arguments, our application starts tomcat automatically on port 8080 as spring provides tomcat as the embedded container. So we do not need any external server for our web application.
Spring boot provides intrisic logging support by using logback, slf4j. So we do not need any external loogers for our web application .
Primary goals of Spring bot according to Spring Site are :-
Iteration1 :
We have made an Employee Management System that consists of Model, View and Controller . We have used maven for build. We have a jsp page addEmployee that contains a form to input various details from the user. We are inputting id, email, address, name and salary of the user. These form details are being submitted and sent as a post request to our controller. Our controller passes these details to our DAO class i.e. EmployeeDAO which then saves these details to in memory derby database. When retriving the details of various employees as a list. We are also calculating the average salary of the employees and displaying the employee with the maximum and minimum salaries.
Iteration2 :
We have added derby as the persistence layer to our application. User can now view all the employees added to the database as a list. With the list of employees, the employee with maximum salary, the employee with minimum salary and the average salary of all the employees is also returned to the user.
Iteration 3 :
For implementing the crud operations, we have added two options of Update and Delete with the list of employees that is returned to the user. If the user clicks on Update, the employee details are displayed on next page , where the user has option to edit all these details. As the id of the Employee is the primary key, the user is not allowed to update hisher id. All other details apart from id can be updated and after editing all the desired fields. The user can click on update to update all his records. The new values are updated to the db. And trhe user is redirected to the home page with the message that all the details of the user with his id are updated successfully. With the Update option a delete option is also provided to the user, if the user clicks on delete all the details of that user are permanently deleted from the database .
Pom.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<project xmlns=”https://maven.apache.org/POM/4.0.0″ xmlns:xsi=”https://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd”>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-boot-web-jsp</artifactId>
<packaging>war</packaging>
<name>Spring Boot Web Employee App</name>
<description>Spring Boot Employee Application</description>
<version>1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!– https://mvnrepository.com/artifact/org.apache.derby/derby –>
<dependency>
<groupId> org.apache.derby </groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<!– Web –>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!– https://mvnrepository.com/artifact/org.hibernate/hibernate-annotations –>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.10.1.1</version>
</dependency>
<!– Web with Tomcat + Embed –>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!– JSTL –>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!– Need this to compile JSP –>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!– Need this to compile JSP –>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.6.1</version>
<scope>provided</scope>
</dependency>
<!– Optional, for bootstrap –>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<!– Package as an executable jar/war –>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Home Page : –
Add Employee : –
List Employees : –
Update Employee : –
Messages displayed on Home Page Example –
Challenges Faced: –
I was getting problem to integrate the Derby in memory database with the Spring boot application. There was some problem with the Locale Files of the Derby that are throwing error. Also, i was getting error in starting the web application and setting the DAO class as a Dependency. I resolved it after doing some research over the internet.
I have integrated the Delete and Update functionality of the Employee records from within the area where the list of employees is being displayed. The uer do not have to go to other pages to do these tasks, The user can simply visit the page where the list of employees is displayed. To delete an employee he/she just clicks on the Delete link displayed there and the employee is deleted from the database. .
Essay Writing Service Features
Our Experience
No matter how complex your assignment is, we can find the right professional for your specific task. Contact Essay is an essay writing company that hires only the smartest minds to help you with your projects. Our expertise allows us to provide students with high-quality academic writing, editing & proofreading services.Free Features
Free revision policy
$10Free bibliography & reference
$8Free title page
$8Free formatting
$8How Our Essay Writing Service Works
First, you will need to complete an order form. It's not difficult but, in case there is anything you find not to be clear, you may always call us so that we can guide you through it. On the order form, you will need to include some basic information concerning your order: subject, topic, number of pages, etc. We also encourage our clients to upload any relevant information or sources that will help.
Complete the order formOnce we have all the information and instructions that we need, we select the most suitable writer for your assignment. While everything seems to be clear, the writer, who has complete knowledge of the subject, may need clarification from you. It is at that point that you would receive a call or email from us.
Writer’s assignmentAs soon as the writer has finished, it will be delivered both to the website and to your email address so that you will not miss it. If your deadline is close at hand, we will place a call to you to make sure that you receive the paper on time.
Completing the order and download