Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
33 views

Weather API Implementation

The document outlines the steps to create a weather API implementation using Spring MVC including creating a Maven project, entity and service classes, performing CRUD operations, and deploying the application on Tomcat. The primary goals are to retrieve weather data from an API, convert it to an Excel sheet, and not validate reports requested more than 15 minutes late. Requirements include setting up the project structure, database, and classes for the entities, services, and controllers.

Uploaded by

Somnath Biswal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Weather API Implementation

The document outlines the steps to create a weather API implementation using Spring MVC including creating a Maven project, entity and service classes, performing CRUD operations, and deploying the application on Tomcat. The primary goals are to retrieve weather data from an API, convert it to an Excel sheet, and not validate reports requested more than 15 minutes late. Requirements include setting up the project structure, database, and classes for the entities, services, and controllers.

Uploaded by

Somnath Biswal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Weather API Implementation

High-Level Approach

1. Create a Maven project using spring MVC.


2. We'll be accepting data (book and user details) to be stored.
3. We'll be adding the functionality to retrieve book details.
4. Once the design is ready, write the controller, service and dao layers to execute the CRUD
operations.
5. Write the tests using mockito

Product Architecture
Implement controllers to handle requests and responses for all the CRUD operations.
In Model set the properties you want to create the response of.
In Service get the methods that are required.

Primary goals

1. Every user should have the following conditions of weather


Get the data from API
Use the data to convert in an excel sheet
2. If the report is asked from other 15 mins or late then dont validate

Requirements

1. Create a maven project using Spring MVC archetype. You can refer to the below reference
to set-up your first maven project using spring archetype to pom xml step wise.
Creating a maven project using in IntelliJ IDEA
2. Create separate packages for controller classes, service classes, entity classes .
Packages in Java
Design Pattern - MVC
3. Auto download any spring dependencies if needed (Check the colour codes in the xml
files- if the colour is red, you need to import the dependency).
Import Spring Dependencies
4. Create a schema in the database and add a new table. The table should consist the below
column names -
Location
Date
Temperature

Creating entity class


A JPA entity class is a POJO (Plain Old Java Object) class, i.e. an ordinary Java class that is
marked (annotated) as having the ability to represent objects in the database. The only unique
JPA addition is the @Entity annotation, which marks the class as an entity class. Check out the
use of Persistent Fields in entity classes.

Requirements

1. Create the entity java class under the entity package.


2. Import the java persistence API library packages (if not auto downloaded). Check below to
find more about JPA imports-
JPA Dependencies
3. Write the code in the entity java class to create a POJO class.

Creating service classes

The service layer is there to provide logic to operate on the data sent to and from the DAO and
the client. Very often these two pieces are bundled together into the same module. Service
layer provides code modularity and can also be used to serve loose coupling in the application.

Requirements

1. Create a service interface and a service implementation class under the service package.
2. Write the four method definition on the interface class-
Get the total customer list
Save customer information
Get the customer list from a given customer id (for update functionality)
Delete customer information
3. Write down the service implementation class by defining the four methods implemented
from the interface.

Requirements

1. Build the project. There are two ways to build a project-

From the IDE terminal


From the CMD
Open the command (CMD) terminal. Go to the path where the project is residing. Run the
below command-

mvn clean install

2. Create a WAR file. If built from IDE. You need to manually build a war file.
Create a WAR file
3. Run the tomcat server from IDE or independently

From IDE. Define and run application server

Else keep the WAR file on the tomcat webapps folder and click on start.bat file present in
the bin folder.
Deploy web application through Tomcat
4. Write down the web URL and start your web application.

https://localhost:<port number>/<home page name>.html/

You might also like