spring-restcontroller

InvalidDefinitionException: Cannot construct instance of `com.vehicle.datatransferobject.VehicleDTO`

元气小坏坏 提交于 2020-06-25 21:18:28
问题 In the REST endpoint I'm building in Spring Boot, I'm trying to pass my vehicleDTO to my controller. But before it reaches my controller, there is an error. InvalidDefinitionException: Cannot construct instance of com.vehicle.datatransferobject.VehicleDTO (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator) vehicleDTO import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude;

Protect Actuator endpoints with user/password while granting public access for RestControllers

南楼画角 提交于 2020-05-28 03:35:45
问题 I updated an already existing application from Spring Boot 1.3 to 2.0.1. This application makes use of the Actuator and exposes a REST-style API. In Boot 1.3 the API could be used without authentication and the actuator endpoint was configured to be password protected: security.user.name=foo security.user.password=bar security-user.role=ADMIN I updated this like documented in the configuration changelog and renamed the entries from security.user.name to spring.security.user.name and alike.

Protect Actuator endpoints with user/password while granting public access for RestControllers

梦想与她 提交于 2020-05-28 03:34:07
问题 I updated an already existing application from Spring Boot 1.3 to 2.0.1. This application makes use of the Actuator and exposes a REST-style API. In Boot 1.3 the API could be used without authentication and the actuator endpoint was configured to be password protected: security.user.name=foo security.user.password=bar security-user.role=ADMIN I updated this like documented in the configuration changelog and renamed the entries from security.user.name to spring.security.user.name and alike.

@RequestParam with any value

北战南征 提交于 2020-05-15 18:19:25
问题 I have the following metod in my @Restcontroller: @GetMapping public List<User> getByParameterOrAll( @RequestParam(value = "email", required = false) String email, @RequestParam(value = "phone", required = false) String phone) { List<User> userList; if ((email != null && !email.isEmpty()) && (phone == null || phone.isEmpty())) { userList = super.getByEmail(email); } else if ((email == null || email.isEmpty()) && (phone != null)) { userList = super.getByPhone(phone); } else { userList = super

Which layer should be used for conversion to DTO from Domain Object

僤鯓⒐⒋嵵緔 提交于 2020-03-18 03:37:32
问题 We are creating rest api's with Spring Boot. We have three layers in our project(Repository, Service and Controller). Lets say I have GetUser api in my controller that return UserDTO object. @GetMapping public UserDTO getUser() { return userService.getUser(); } Whether userService.getUser() returns UserDTO object or it returns User object and it is converted to UserDTO object in the controller? Which one is better way? Shortly, domain object to DTO object conversion, should be done in service

Restful-based video streaming

ⅰ亾dé卋堺 提交于 2020-02-20 09:32:46
问题 Using spring boot, I want to make RESTful-based video player. I have my .mp4 extension videos in my file browser. How can I serve these videos on the frontend side by creating a rest endpoint? I've tried this method. The video can be started or stopped. But it can not be done backwards or forwards. Can not get it to the desired minute and start. 回答1: Spring Content supports video streaming out of the box. Using Spring Content for the file-system (FS) you would be able to create yourself a

spring rest dynamically exclude Object properties from serialization

时光总嘲笑我的痴心妄想 提交于 2020-01-30 08:39:26
问题 i want to exclude specific properties of spring rest response body. after hours of googling around i found this: http://www.jroller.com/RickHigh/entry/filtering_json_feeds_from_spring due to its date i like to ask if there is something more up-to-date for jackson and or fasterxml. JsonView doesnt fit my requirements as i need to have such case covered: if A is the set of all my attributes: one time i need to expose B with B ⊂ A. another time C with C ⊂ A. And B ∩ C != ∅ this would cause

spring rest dynamically exclude Object properties from serialization

耗尽温柔 提交于 2020-01-30 08:39:10
问题 i want to exclude specific properties of spring rest response body. after hours of googling around i found this: http://www.jroller.com/RickHigh/entry/filtering_json_feeds_from_spring due to its date i like to ask if there is something more up-to-date for jackson and or fasterxml. JsonView doesnt fit my requirements as i need to have such case covered: if A is the set of all my attributes: one time i need to expose B with B ⊂ A. another time C with C ⊂ A. And B ∩ C != ∅ this would cause

Custom controller without view name

扶醉桌前 提交于 2020-01-24 01:08:19
问题 I'm investigating now on how Spring Controller layer actually works. If I want to have a controller that returns a model and view name (e.g. HTML file name) I just extend AbstractController class, then implement a handleRequestInternal method, registering that controller as a bean, and setting in my HandlerMapping (e.g. SimpleUrlHandlerMapping) what path is mapped to what controller. But that forces me to return view name. What if I would like to not specify the view name, and just return

Custom controller without view name

社会主义新天地 提交于 2020-01-24 01:08:05
问题 I'm investigating now on how Spring Controller layer actually works. If I want to have a controller that returns a model and view name (e.g. HTML file name) I just extend AbstractController class, then implement a handleRequestInternal method, registering that controller as a bean, and setting in my HandlerMapping (e.g. SimpleUrlHandlerMapping) what path is mapped to what controller. But that forces me to return view name. What if I would like to not specify the view name, and just return