Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spring.datasource.url=jdbc:mysql://localhost:3306/springbootfirstapp
- spring.datasource.username=root
- spring.datasource.password=
- spring.datasource.driver-class-name=com.mysql.jdbc.Driver
- spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
- spring.jpa.hibernate.ddl-auto=update
- package springbootfirstapp.controller;
- import java.util.List;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.bind.annotation.RestController;
- import springbootfirstapp.domain.Customer;
- import springbootfirstapp.repo.CustomerRepo;
- @RestController
- @RequestMapping("/customer")
- public class CustomerController {
- @Autowired
- CustomerRepo rp;
- @RequestMapping("/findall")
- @ResponseBody
- public List<Customer> findall(){
- return rp.findAll();
- }
- }
- package springbootfirstapp.domain;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- @Entity
- public class Customer {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private int id;
- private String name;
- private int phone;
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getPhone() {
- return phone;
- }
- public void setPhone(int phone) {
- this.phone = phone;
- }
- public Customer(int id, String name, int phone) {
- super();
- this.id = id;
- this.name = name;
- this.phone = phone;
- }
- public Customer() {
- super();
- }
- }
- package springbootfirstapp.repo;
- import org.springframework.data.jpa.repository.JpaRepository;
- import springbootfirstapp.domain.Customer;
- public interface CustomerRepo extends JpaRepository<Customer, Integer> {
- }
- spring.datasource.url=jdbc:mysql://localhost:3306/springbootfirstapp
- spring.datasource.username=root
- spring.datasource.password=
- spring.datasource.driver-class-name=com.mysql.jdbc.Driver
- spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
- spring.jpa.hibernate.ddl-auto=update
Add Comment
Please, Sign In to add comment