spring-rest

Spring Pageable does not translate @Column name

大兔子大兔子 提交于 2020-02-24 14:39:35
问题 I have Entity object : @Entity(name = "table") public class SomeEntity { @Id @Column(name = "id_column_name") public final BigDecimal entityId; @Column(name = "table_column_name") public final String entityFieldName; } And I have database view defined like this: CREATE OR REPLACE FORCE EDITIONABLE VIEW "V_TABLE" ("ID_COLUMN_NAME", "TABLE_COLUMN_NAME", "SOME_OTHER_COLUMN") AS ... (some SQL magic) And I have repository with custom query: @RepositoryRestResource interface SomeEntityRepository

How to by default execute the latest version of endpoint in Spring Boot REST?

不羁的心 提交于 2020-02-23 07:14:39
问题 I'm developing Spring Boot v2.2.2.RELEASE and API versioning using Custom Header. By default I want latest version of endpoint to be executed. Here in below code its X-API-VERSION=2 . Before executing the endpoint I need to check mapping and then set the latest version in for the Custom Header and then execute it. @GetMapping(value = "/student/header", headers = {"X-API-VERSION=1"}) public StudentV1 headerV1() { return serviceImpl.headerV1(); } @GetMapping(value = "/student/header", headers =

How to wrap Path Not Found Exception in Spring Boot Rest using ExceptionHandler?

空扰寡人 提交于 2020-01-30 03:34:11
问题 I am using Spring Boot and Spring Rest Example . In this example, I am passing custom header, if that value is valid, endpoint gets called successfully, if custom header value is not correct then I get below response, which I want to wrap into show it to the enduser using @ControllerAdvice ExceptionHandler. Note: I went through Spring mvc - How to map all wrong request mapping to a single method, but here in my case I am taking decision based on CustomHeader, please guide me. { "timestamp":

Why is SpringFox not exposing @RepositoryRestResource?

╄→гoц情女王★ 提交于 2020-01-30 02:40:16
问题 I have created a @RepositoryRestResource @RepositoryRestResource(collectionResourceRel = "tracks", path = "tracks") public interface TrackRepository extends PagingAndSortingRepository<TrackEntity, Long> { } in addition to some other @RestController : @RestController @RequestMapping("/api") public class UserController { private UserService userService; @Autowired public UserController(UserService userService) { this.userService = userService; } @RequestMapping(value = "/users", method =

Spring HATEOAS - two same links

橙三吉。 提交于 2020-01-24 20:41:11
问题 lately I've been doing some projekt with Spring Data and Rest with HATEOAS. My question is, is it normal, that in entity links secion, I have 2 same links? Here is repository: Repository 回答1: Yes it is. But it's not always the case: the 'user' link is actually a templated link that gets enriched in certain cases. For instance, should you define the following projection: @Projection(name = "summary", types = { User.class }) interface Summary { String getUsername(); String getEmail(); } then

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

Spring RestTemplate getForObject URL not working for Apple iTunes

放肆的年华 提交于 2020-01-23 12:35:08
问题 I created the following simple test to query iTunes: @Test fun loadArtist() { val restTemplate = RestTemplate() val builder = UriComponentsBuilder.fromHttpUrl("https://itunes.apple.com/search") builder.queryParam("term", "howling wolf") builder.queryParam("entity", "allArtist") builder.queryParam("limit", 1) println("\n\nURL ${builder.toUriString()}") val result = restTemplate.getForObject(builder.toUriString(), String::class.java); println("Got artist: $result") } And the output was

Spring asynch method integration test fails

白昼怎懂夜的黑 提交于 2020-01-16 20:19:26
问题 I created an integration test for asynchronous rest controller method. Which looks like: @Test public void shouldHandleRequestsAsynchronously() throws Exception { MvcResult mvcResult = this.mockMvc.perform(get("/api/reports/daily?startDate=2004-04-13&endDate=2005-04-13")) .andExpect(request().asyncStarted()) .andReturn(); this.mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(jsonPath("$[0].totalDistance", equalTo(100))) .andExpect(jsonPath("$[0].totalPrice",

Spring asynch method integration test fails

安稳与你 提交于 2020-01-16 20:19:09
问题 I created an integration test for asynchronous rest controller method. Which looks like: @Test public void shouldHandleRequestsAsynchronously() throws Exception { MvcResult mvcResult = this.mockMvc.perform(get("/api/reports/daily?startDate=2004-04-13&endDate=2005-04-13")) .andExpect(request().asyncStarted()) .andReturn(); this.mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(jsonPath("$[0].totalDistance", equalTo(100))) .andExpect(jsonPath("$[0].totalPrice",