Весенний ботинок | Запросы почтальона заканчиваются 404MySql

Форум по Mysql
Ответить
Anonymous
 Весенний ботинок | Запросы почтальона заканчиваются 404

Сообщение Anonymous »

Запросы почтальона заканчиваются 404 для Spring Boot Project.
код приведен ниже. С нетерпением жду поддержки. < /P>
Класс объектов: < /p>

Код: Выделить всё

package com.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

@Entity
@Table(name = "CustomerDetails")
public class CustomerEntity {

@Column(name = "CustomerName")
private String name;
@Column(name = "PhoneNumber")
private Long phone;
@Id
@Column(name = "Email")
private String email;

public CustomerEntity() {
}

public CustomerEntity(String name, Long phone, String email) {
this.name = name;
this.phone = phone;
this.email = email;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Long getPhone() {
return phone;
}

public void setPhone(Long phone) {
this.phone = phone;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

@Override
public String toString() {
return "CustomerEntity{" +
"name='" + name + '\'' +
", phone=" + phone +
", email='" + email + '\'' +
'}';
}
}

< /code>
Repository: < /p>
package com.repository;

import com.accenture.entity.CustomerEntity;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CustomerRepository extends JpaRepository {
}

< /code>
Service: < /p>
package com.service;

import com.accenture.entity.CustomerEntity;
import com.accenture.repository.CustomerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerService {

@Autowired
private CustomerRepository customerRepository;

public List getCustomerDetails(){
return customerRepository.findAll();
}

public CustomerEntity saveCustomerDetails(CustomerEntity customerEntity){
return customerRepository.save(customerEntity);
}
}

< /code>
контроллер: < /p>
package com.controller;

import com.accenture.entity.CustomerEntity;
import com.accenture.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/customer")
public class CustomerController {

@Autowired
private CustomerService customerService;

@GetMapping("/getCustomerDetails")
public List  getCustomerDetails(){
return customerService.getCustomerDetails();
}
@PostMapping("/addCustomer")
public CustomerEntity postCustomerDetails(@RequestBody CustomerEntity customerEntity){
return customerService.saveCustomerDetails(customerEntity);
}
}

< /code>
main: < /p>
package com.Application;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

}

< /code>
application.properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3307/mydb
spring.datasource.username=root
spring.datasource.password=root

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

spring.jpa.generate-ddl=true
http: // localhost: 8080/customer/getCustomerDetails -> 404 Не найдено
http: // localhost: 8080/customer/addcustomer -> 404 не найден (данные правильно приведены в формате json)
{br/
"2025-07-03T07: 45: 18.484+00: 00",
"Статус": 404,
"ошибка": "не найден",
"path": " /customer /getCustomerDetails"
} < /p> wressman wressman wressman wressman wressman wressman wressman wresting wresting wresting.>

Подробнее здесь: https://stackoverflow.com/questions/796 ... g-with-404
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «MySql»