Spring Boot Session-2
Spring Boot Session-2
Step 3: Spring Tool Suite 4 Launcher dialog box appears on the screen.
Click on the Launch button. Here give your Workspace location if required.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Creating a Spring Boot Project Using STS
-------------------------------------------------------------------
Step 1: Open the Spring Tool Suite.
Step 2: Click on the File menu -> New -> Maven Project
Step5: open application.java --> it is main file to exexute our spring boot
application.
suppose you want to change server port number then go with
application.properties file
in that type
server.port:portnumber
server.port:2022
localhost:8080
localhost:2022
127.0.0.1:2022
INVASIVE:
ex:
---
servlet class
struts
ex:
---
class Myservlet implements Servlet
{
}
class Myservlet extends GenericServlet
{
}
class Myservlet extends HttServlet
{
---------------------------------
Controller
-----------------
class MyControlle implements Controller
{
public ModelAndView handleRequest(-,-)
{
}
------------------------------------------------
NON-INvasive
----------------
@Controller
class MyController
{
@RequestMapping("/url1")
@ResponseBody
public String mymethod()
{
return "string data";
}
}
==========================================================
MyController.java
----------------
package com.stech;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class MyController {
@RequestMapping("/url1")
@ResponseBody
public String show() {
return "Welcome Spring Boot";
}
@RequestMapping("/url2")
@ResponseBody
public String about() {
return "Welcome About web Page";
}
}