Когда я выполняю операцию публикации/удаления из почтальона, я получаю код ошибки 404, но данные успешно вставляются или удаляются в мою базу данных. Я не могу понять, почему мой код ведет себя так. Публикация скриншота
базы данных,
ответа API
класса контроллера
@Controller
public class UserController {
@Autowired
private UserService userService;
@PostMapping("/user/add")
public void addNewUser(@RequestBody User user) throws BLException {
userService.addNewUser(user);
}
@DeleteMapping("/user/delete/{id}")
public void deleteById(@PathVariable int id){
userService.deleteById(id);
}
@DeleteMapping("/deleteAll")
public void deleteAll(){
userService.deleteAll();
}
}
Класс обслуживания
@Service
public class UserService {
@Autowired
public UserRepository userRepository;
public void addNewUser(User user) throws BLException {
try {
ValidateMobileNumber.validate(user.getPhone());
userRepository.save(user);
}
catch (BLException e){
System.out.println(e.getMessage());
}
}
public void deleteById(int id){
userRepository.deleteById(id);
}
public void deleteAll(){
userRepository.deleteAll();
}
}
Файл build.gradle
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
// https://mvnrepository.com/artifact/org. ... spring-web
implementation group: 'org.springframework', name: 'spring-web', version: '5.3.16'
// https://mvnrepository.com/artifact/io.s ... x-swagger2
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
// https://mvnrepository.com/artifact/org. ... tarter-web
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.6.3'
// https://mvnrepository.com/artifact/org. ... arter-jdbc
// https://mvnrepository.com/artifact/org. ... bok/lombok
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.22'
// https://mvnrepository.com/artifact/org. ... ta-commons
implementation group: 'org.springframework.data', name: 'spring-data-commons', version: '2.6.1'
// https://mvnrepository.com/artifact/org. ... t-devtools
implementation group: 'org.springframework.boot', name: 'spring-boot-devtools', version: '2.6.3'
// https://mvnrepository.com/artifact/org. ... ectjweaver
implementation group: 'org.aspectj', name: 'aspectjweaver', version: '1.9.8'
// https://mvnrepository.com/artifact/org. ... /aspectjrt
implementation group: 'org.aspectj', name: 'aspectjrt', version: '1.9.8'
// https://mvnrepository.com/artifact/aopa ... opalliance
implementation group: 'aopalliance', name: 'aopalliance', version: '1.0'
// https://mvnrepository.com/artifact/cglib/cglib
implementation group: 'cglib', name: 'cglib', version: '3.3.0'
// https://mvnrepository.com/artifact/org.ow2.asm/asm
implementation group: 'org.ow2.asm', name: 'asm', version: '9.2'
// https://mvnrepository.com/artifact/com. ... n-databind
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.0.1'
// https://mvnrepository.com/artifact/org. ... r-data-jpa
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.7.2'
// https://mvnrepository.com/artifact/mysq ... ector-java
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.30'
// https://mvnrepository.com/artifact/org. ... arter-jdbc
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: '2.7.2'
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.4'
}
test {
useJUnitPlatform()
}
Подробнее здесь: https://stackoverflow.com/questions/734 ... ta-is-succ
Я получаю код ошибки 404 при выполнении почтового запроса, но данные успешно вставляются в базу данных при весенней загр ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение