ПРИЛОЖЕНИЕ НЕ ЗАПУСКАЕТСЯ
Описание:
Полю proxy в com.example.Javer.controllers.JaverController требовался bean-компонент типа com.example.Javer.proxy.TransactionServiceProxy, который мог не быть найдено.
Точка внедрения имеет следующие аннотации:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Действие:
Рассмотрите возможность определения bean-компонента типа com.example.Javer.proxy.TransactionServiceProxy в вашей конфигурации.
Код: Выделить всё
controllerКод: Выделить всё
package com.example.Javer.controllers;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.example.Javer.dto.ClientCreateDto;
import com.example.Javer.dto.ClientResponseDto;
import com.example.Javer.proxy.TransactionServiceProxy;
@RestController
@RequestMapping("/servico/clientes")
public class JaverController {
@Autowired
private TransactionServiceProxy proxy;
@GetMapping
public ResponseEntity getAll() {
return proxy.getAllClients();
}
@PostMapping
public ResponseEntity create(@RequestBody ClientCreateDto dto) {
return proxy.createClient(dto);
}
@PutMapping("/{id}")
public ResponseEntity update(@PathVariable Long id, @RequestParam Float newBalance) {
return proxy.updateBalance(id, newBalance);
}
@DeleteMapping("/{id}")
public ResponseEntity delete(@PathVariable Long id) {
return proxy.deleteClient(id);
}
}
Код: Выделить всё
proxyКод: Выделить всё
package com.example.Javer.proxy;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
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.RequestParam;
import com.example.Javer.dto.ClientCreateDto;
import com.example.Javer.dto.ClientResponseDto;
@FeignClient(name = "service", url = "http://localhost:8080")
public interface TransactionServiceProxy {
@GetMapping
public ResponseEntity getAllClients();
@PostMapping
public ResponseEntity createClient(@RequestBody ClientCreateDto dto);
@PutMapping("/{id}")
public ResponseEntity updateBalance(@PathVariable Long id, @RequestParam Float newBalance);
@DeleteMapping("/{id}")
public ResponseEntity deleteClient(@PathVariable Long id);
}
Код: Выделить всё
applicationКод: Выделить всё
package com.example.Javer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class JaverApplication {
public static void main(String[] args) {
SpringApplication.run(JaverApplication.class, args);
}
}
Код: Выделить всё
application.propertiesКод: Выделить всё
spring.application.name=Javer
server.port=8081
spring.datasource.url=jdbc:h2:mem:javer
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=nss
spring.datasource.password=
spring.h2.console.enabled=true
Подробнее здесь: https://stackoverflow.com/questions/793 ... dar-spring
Мобильная версия