CalcController.java
package com.javatest.demo;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
class MyCalc {
private int num1;
private int num2;
public int getNum1() {
return num1;
}
public void setNum1(int num1) {
this.num1 = num1;
}
public int getNum2() {
return num2;
}
public void setNum2(int num2) {
this.num2 = num2;
}
@Override
public String toString() {
return "MyCalc [num1=" + num1 + ", num2=" + num2 + "]";
}
}
@RestController
public class CalcController {
@RequestMapping("test")
public String test() {
return "Testing....";
}
/** Read query params */
@RequestMapping("mycalc")
@GetMapping
public String getMet(@RequestParam("num1") int x, @RequestParam int y) {
return String.format("%s + %s = %s", x, y, x+y);
}
/** Read raw json data */
@PostMapping("mycalc")
public String postMet(@RequestBody MyCalc obj) {
int x = obj.getNum1();
int y = obj.getNum2();
return String.format("%s - %s = %s", x, y, x - y);
}
/** Read form data */
@PutMapping("mycalc")
public String putMet(
@RequestParam("num1") int x,
@RequestParam("num2") int y) {
return String.format("%s * %s = %s", x, y, x * y);
}
/** Read from raw json */
@DeleteMapping("mycalc")
public String deleteMet(@RequestBody MyCalc obj) {
int x = obj.getNum1();
int y = obj.getNum2();
return String.format("%s / %s = %s", x, y, x / y);
}
}
src/main/resources/application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/<databasename>
spring.datasource.username=<username>
spring.datasource.password=<password>
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
User.java (POJO/DAO/JPA)
package com.javatest.demo;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name="users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String age;
private String city;
private int quota;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public int getQuota() {
return quota;
}
public void setQuota(int quota) {
this.quota = quota;
}
// getters and setters
}
UserController.java
package com.javatest.demo;
import java.util.List;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.data.jpa.repository.JpaRepository;
interface UserRepository extends JpaRepository<User, Long> {
// Custom queries can be defined here
}
@RestController
@RequestMapping("users")
public class UserController {
private final UserRepository userRepository;
public UserController(UserRepository userRepository) {
this.userRepository = userRepository;
}
@RequestMapping("")
public String index() {
return "I am from index";
}
@RequestMapping("listing")
public List<User> listing() {
// List<User> users = new ArrayList<>();
return userRepository.findAll();
}
@DeleteMapping("delete/{id}")
public String deleteUser(@PathVariable Long id) {
// Check if the user with the specified ID exists
if (userRepository.existsById(id)) {
userRepository.deleteById(id);
return String.format("User %s is deleted successfully", id);
} else {
// Handle the case when the user does not exist (e.g., return an error response)
// You can throw an exception or return an appropriate response based on your application's requirements.
}
return "";
}
@PostMapping("create")
public User createUser(@RequestBody User user) {
return userRepository.save(user);
}
@GetMapping("get-single/{id}")
public User getUserById(@PathVariable Long id) {
// Use the UserRepository to fetch the user by ID
return userRepository.findById(id).orElse(null);
}
@PutMapping("/update/{id}")
public User updateUser(@PathVariable Long id, @RequestBody User updatedUser) {
// Check if the user with the specified ID exists
userRepository.findById(id).orElse(null);
// Set the ID of the updated user to the specified ID
updatedUser.setId(id);
// Save the updated user to the database
return userRepository.save(updatedUser);
}
}
DemoApplication.java (Run this file to serve spring boot application)
package com.javatest.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
File Structure
.
├── HELP.md
├── mvnw
├── mvnw.cmd
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── javatest
│ │ │ └── demo
│ │ │ ├── CalcController.java
│ │ │ ├── DemoApplication.java
│ │ │ ├── User.java
│ │ │ └── UserController.java
│ │ └── resources
│ │ ├── application.properties
│ │ ├── static
│ │ └── templates
│ └── test
│ └── java
│ └── com
│ └── javatest
│ └── demo
│ └── DemoApplicationTests.java
└── target
├── classes
│ ├── application.properties
│ └── com
│ └── javatest
│ └── demo
│ ├── CalcController.class
│ ├── DemoApplication.class
│ ├── MyCalc.class
│ ├── User.class
│ ├── UserController.class
│ └── UserRepository.class
└── test-classes
└── com
└── javatest
└── demo
└── DemoApplicationTests.class
23 directories, 18 files
POC





VSCode Extesnsions


Spring Boot Web + JPA + MySQL
Got it ✅
Let’s build this from scratch, step by step, including MySQL dependency so you’re future-ready but you can still just run Hello World without DB config.
🚀 Spring Boot Hello World (with future MySQL support) in VS Code
1. Prerequisites
Check you have these installed:
java -version # Java 17 or 21 recommended
mvn -v # Maven installed
VS Code Extensions:
- Extension Pack for Java
- Spring Boot Extension Pack (optional but helpful)
2. Generate Spring Boot Project
Option A (VS Code)
- Press
Ctrl+Shift+P→ searchSpring Initializr: Create a Maven Project. - Select:
- Spring Boot version: 3.x (latest)
- Project: Maven
- Language: Java
- Group Id:
com.example - Artifact Id:
hello - Dependencies:
Spring Web,Spring Data JPA,MySQL Driver
- It will create and open the project in VS Code.
Option B (Browser)
Go to 👉 https://start.spring.io
Choose:
- Maven Project, Java, Spring Boot
3.x - Group:
com.example - Artifact:
hello - Dependencies:
Spring Web,Spring Data JPA,MySQL Driver
Download → unzip → open folder in VS Code.
3. Project Structure
You’ll see:
hello/
├─ src/main/java/com/example/hello/
│ ├─ HelloApplication.java
│ └─ controller/HelloController.java (we’ll create)
├─ src/main/resources/
│ ├─ application.properties
├─ pom.xml
4. Minimal pom.xml
Your pom.xml should contain (important part only):
<dependencies>
<!-- Spring Web for REST APIs -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- MySQL JDBC Driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<!-- JPA (for DB support in future) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
⚡ Even if MySQL is not configured, the app will still run fine.
5. Application Entry Point
Generated file → HelloApplication.java:
package com.example.hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
}
6. Create Controller
Create folder controller under com.example.hello.
File: HelloController.java
package com.example.hello.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public String hello() {
return "Hello World";
}
}
7. Run the Application
In VS Code terminal:
mvn spring-boot:run
Or run HelloApplication.java directly via Run → Start Debugging.
8. Test in Browser / Curl
Visit:
http://localhost:8080/hello
Output:
Hello World
9. (Future) MySQL Connection Setup
When you’re ready to use MySQL, edit src/main/resources/application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=secret
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
Then you can create Entity + Repository classes for DB operations.
✅ That’s it — you now have:
- A working Hello World REST API (
/hello) - MySQL support already included for future use
apuestas atletico barcelona, Buddy, atletico madrid
Como se calculan las cuotas de Apuestas caballos colocado
que significa stake 1 en apuestas
Feel free to visit my page :: Basketball-wetten.Com
como ganar apuestas Deportivas listado (aracatuba.odontoexcellence.Com.br)
combinadas
seriöse sportwetten anbieter (http://www.Transwkuwait.com) bonus
ohne einzahlung österreich
mejores casas apuestas tenis en tenis de mesa
free sportwetten bonus ohne einzahlung
My site wetten spanien Deutschland
gratis wette ohne einzahlung
My webpage Sportwetten seite Erstellen
esc buchmacher deutschland
my blog: basketball Wetten prognosen
die besten wettstrategien
Also visit my web blog; buchmacher beste quoten (Lottie)
canadian poker stars, united states online what is a cash Advance at casino slots and legal age for
gambling in united states, or bingo how to play uk
no deposit online pokies nz, gambling in ontario australia and play online usa roulette, or new
how to win every time at casino (Randy) uk
888 poker new zealand blackjack with side bets app; Muhammad,,
real usa online casino and online poker real money usa 2021, or
online casino bc australia
best way to win united kingdom roulette, how to play online poker for money in canada
and gambling legislation australia, or united statesn slots miami
Also visit my site … casino gods bonus codes [Sang]
top online pokies and casinos united states pokies,
united statesn online poker machines and new zealandn do you need id for casino; Darcy,
no deposit bonus codes, or best rated united kingdom online casino
online keno for real money australia, gambling in ontario australia and do you pay tax
on Casino Games 88 Fortunes winnings in australia,
or bet365 play united statesn roulette online uk
bingo slots uk, online gambling laws in canada and online pokies paysafe canada, or poker sites australia 2021
Here is my web blog – easy win roulette
usa android casino lviv ukraine (Ashlee) bonus, real money united
statesn pokies and best free slots united states, or free online pokies no deposit united kingdom
apuestas para el clasico
My website :: Basketball-Wetten.Com
These are really enormous ideas what is a bankroll in gambling,
Buford, about blogging.
You have touched some good factors here. Any way keep up wrinting.
apuestas combinadas recomendadas
Review my web blog – basketball-wetten.com
free online slots nz, united kingdom online noble casino no deposit bonus (Kristine) free chip and bug bausaai slots, or new casino canada
I am genuinely glad to glance at this blog posts which carries tons of helpful facts,
thanks for providing these data.
Feel free to visit my site … spectacle Casino montreal fevrier 2022
new zealandn online pokies au reviews, casinos no deposit bonus uk and usa casino fast
withdrawal, or bet365 play united statesn roulette wind creek online
casino promo code (Charlene) uk
That how late is desert diamond casino open a really good tip especially to those new to the blogosphere.
Brief but very precise info Appreciate your sharing this one.
A must read article!
25 free spins casino new zealand, bitcoin Can i win money gambling united kingdom and top 10 usa gambling sites, or best casino cities in united kingdom
casino usa free spins for year, gousaos quest free spins
no deposit and online slot casino uk, or uk bingo call
Also visit my webpage … Goplayslots.Net
ausaa ca casino, online casino instant withdrawal uk and free online united kingdom casino, or free spin casino no deposit united states
Look into my homepage; Antoine Walker Gambling Jordan
united kingdom casino guide 2021 review, casino make a living from online roulette
free spins no deposit uk and $5 minimum deposit casino australia 2021, or uk gambling forum
jackpot city doubledown casino stock, Jada, online united states, no id casino uk and can i use td united states trust visa debit
for online gambling, or new zealandn roulette games
new usa online casinos no deposit bonuses, free casino no deposit united
states and what is free number in bingo usa cash bingo, or deposit 10 get usa
An impressive share! I have just forwarded this onto a colleague
who was doing a little homework on this. And he actually ordered me breakfast because I stumbled upon it for him…
lol. So let me reword this…. Thanks for the meal!!
But yeah, thanks for spending the time to discuss this topic here on your internet site.
Here is my blog post: blackjack elasto-kool 1000 reviews (Reagan)