SDET Interview Question and Answers.
Jenkins Interview Questions and Answers.
Appium Interview Questions and Answers
Selenium Interview Questions and answers.
GIT Interview Questions and Answers
Spring is an application framework for the Java platform. It helps you build modern web applications with support for microservice architecture, cloud systems, reactive processing, and serverless workloads.
This tutorial describes how to create and run a Springapplication in IntelliJ IDEA. This will be a Spring Boot Maven project generated by Spring InitializrThis is the quickest way to create a Spring application and IntelliJ IDEA provides a dedicated project wizard for it. You will learn how to expose an HTTP endpoint and map it to a method that returns a greeting to the user when accessed through a web browser.
Create a new Spring Boot project
1. From the main menu, select File | New | Project.
2. In the left pane of the New Project wizard, select Spring Initializr.
3. Specify a name for the project: spring-boot-tutorial.
4. From the JDK list, select Download JDK and download the latest version of Oracle 5. OpenJDK.
6. Select the latest Java version.
7. Click Next to continue.
8. Select Spring Web Dependency under Web. This dependency is required for any web application that uses Spring MVC.
9. Click Create to generate and set up the project.
Add a method that sends a greeting
Spring Initializr creates a class with the main() method to bootstrap your Spring application. In this tutorial, we'll add the sayHello() method directly to this class.
Open the SpringBootTutorialApplication.java file under src/main/java/com/example/springboottutorial.
IntelliJ IDEA provides the Go to File action to quickly find and open files. From the main menu, select Navigate | File or press ⇧ ⌘ O, start typing the name of the file and select it from the list.
Add the sayHello() method with all of the necessary annotations and imports so that the file looks like this:
The sayHello() method takes the name parameter and returns the word Hello combined with the parameter value. Everything else is handled by adding Spring annotations:
- The @RestController annotation marks the SpringBootTutorialApplication class as a request handler (a REST controller).
- The @GetMapping("/hello") annotation maps the sayHello() method to GET requests for /hello.
- The @RequestParam annotation maps the name method parameter to the myName web request parameter. If you don't provide the myName parameter in your web request, it will default to World.
Run your Spring application
IntelliJ IDEA creates a Spring Boot run configuration that you can use to run your new Spring application.
If the run configuration is selected, press ⌃ R.
You can also use the icon in the gutter of the SpringBootTutorialApplication.java file next to the class declaration or the main() method declaration.
By default, IntelliJ IDEA shows your running Spring Boot application in the Run tool window.
The Console tab shows the output of Spring log messages. By default, the built-in Apache Tomcat server is listening on port 8080. Open your web browser and go to http://localhost:8080/hello. If you did everything right, you should see your application respond with Hello World!.
This is the default generic response. You can provide a parameter in your web request to let the application know how to greet you properly. For example, try http://localhost:8080/hello?myName=Human.
Add a home page
The created Spring Boot application has one endpoint available at /hello. However, if you open the root context of your application at http://localhost:8080/, you will get an error because there is no root resource defined. Let's add a static HTML home page with links to your endpoint.
Create the index.html file under /src/main/resources/static/.
In the Project tool window, right-click the /src/main/resources/static/ directory, select New | HTML File, specify the name index.html, and press Enter.
Modify the default template or replace it with the following HTML code:
In the Run tool window, click or press ⌃ R to restart your Spring application.
Now your application will serve index.html as the root resource at http://localhost:8080/.
****************************************
TOP 15 BDD - CUCUMBER Interview Q&A
************************************************
✍️AUTHOR: LinkedIn Profile
************************************************
Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session
*************************************************
SeleniumWebdriver Automation Testing Interview Questions:
https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver
API Testing Interview Question Set:
https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html
DevOps Interview Q&A:
https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes
Docker Interview Question Set
https://automationreinvented.blogspot.com/Docker
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign
Java Related Interview Question Set
https://automationreinvented.blogspot.com/search/label/Java
GIT Interview Question Set:
https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html
Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions
Mobile Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Mobile%20Testing
Python Interview Question Set for QAE - SDET - SDE:
https://automationreinvented.blogspot.com/search/label/Python
No comments:
Post a Comment