spring-rest

Generic Repository in Spring JPA

烈酒焚心 提交于 2019-12-02 06:00:52
We are working on a Restful project with lots of DB tables. Though the operations on the tables are almost same and mainly INSERT/UPDATE/DELETE/FETCH. my questions is: will we have to create a repository (extending JpaRepository) for every entity (Domain class) we create or, there is an option of creating a GenericRepository that can handle all the above-mentioned functionalities for all the entities? i.e a single GenericRepository for all. if so, could you share an example? is [there] an option of creating a GenericRepository that can handle all the above-mentioned functionalities for all the

Spring rest resource change path

天涯浪子 提交于 2019-12-02 03:21:00
问题 I currently have a repository annotated with @RepositoryRestResource . I'm adding the following: @RestResource(path="make", rel = "make", description = @Description("Get vehicles by make")) List<Vehicle> findByMake(@Param("make") String make); This works fine but the path by default is api/vehicles/search/make . How can I remove the /search part and just have the path be api/vehicles/make ? 回答1: Unfortunately it's not possible. I make some research in Spring Data Rest source code. There are

How to have PersistentEntityResourceAssembler injected into request methods of custom @RepositoryRestController in a @WebMvcTest unit test

流过昼夜 提交于 2019-12-02 01:00:17
问题 Overview How can I have a PersistentEntityResourceAssembler properly injected into my custom REST controller's request methods during a @WebMvcTest unit test? First SO question. Apologies in advance, probably just missing something stupid. Sample code available on GitHub. Oliver Gierke, where you at? :P Details I have a custom REST controller annotated with @RepositoryRestController . Some of its request methods have a PersistentEntityResourceAssembler injected as an argument so I can return

Spring rest resource change path

江枫思渺然 提交于 2019-12-01 23:28:19
I currently have a repository annotated with @RepositoryRestResource . I'm adding the following: @RestResource(path="make", rel = "make", description = @Description("Get vehicles by make")) List<Vehicle> findByMake(@Param("make") String make); This works fine but the path by default is api/vehicles/search/make . How can I remove the /search part and just have the path be api/vehicles/make ? Unfortunately it's not possible. I make some research in Spring Data Rest source code. There are constants that uses for URI building in RepositorySearchController.java : private static final String SEARCH

How to have PersistentEntityResourceAssembler injected into request methods of custom @RepositoryRestController in a @WebMvcTest unit test

你离开我真会死。 提交于 2019-12-01 22:16:22
Overview How can I have a PersistentEntityResourceAssembler properly injected into my custom REST controller's request methods during a @WebMvcTest unit test? First SO question. Apologies in advance, probably just missing something stupid. Sample code available on GitHub . Oliver Gierke, where you at? :P Details I have a custom REST controller annotated with @RepositoryRestController . Some of its request methods have a PersistentEntityResourceAssembler injected as an argument so I can return HAL resources. @RepositoryRestController @RestController @RequestMapping(produces = MediaTypes.HAL

spring jpa - At least one JPA metamodel must be present*

半城伤御伤魂 提交于 2019-12-01 19:54:05
Anybody know why it doesn't work? Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 06/04/2017 14:11:24.732 ERROR [main] - org.springframework.boot.SpringApplication: Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one JPA metamodel must be present! at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory

How to configure spring's RestTemplate to make http2 requests?

孤者浪人 提交于 2019-12-01 19:38:24
I have a RestClient calling GET Requests to a spring service(server), that server is accepting HTTP2 requests and i'm getting 302 as response. How to send Http2 requests using spring RestTemplate. Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://example.com/static/mobile/get-token": unexpected end of stream on Connection{domain.com:443, proxy=DIRECT hostAddress=example.com cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=http/1.1}; nested exception is java.io.IOException: unexpected end of stream on Connection

How to configure spring's RestTemplate to make http2 requests?

孤街醉人 提交于 2019-12-01 19:19:53
问题 I have a RestClient calling GET Requests to a spring service(server), that server is accepting HTTP2 requests and i'm getting 302 as response. How to send Http2 requests using spring RestTemplate. Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://example.com/static/mobile/get-token": unexpected end of stream on Connection{domain.com:443, proxy=DIRECT hostAddress=example.com cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

spring jpa - At least one JPA metamodel must be present*

我的梦境 提交于 2019-12-01 16:56:01
问题 Anybody know why it doesn't work? Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 06/04/2017 14:11:24.732 ERROR [main] - org.springframework.boot.SpringApplication: Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one JPA metamodel must

Testing a custom RepositoryRestController that uses a PersistentEntityResourceAssembler

◇◆丶佛笑我妖孽 提交于 2019-12-01 06:53:22
问题 I have a RepositoryRestController that exposes resources for some persistent entities. I have a method on my controller that takes a PersistentEntityResourceAssembler to help me generate the resources automatically. @RepositoryRestController @ExposesResourceFor(Customer.class) @RequestMapping("/api/customers") public class CustomerController { @Autowired private CustomerService service; @RequestMapping(method = GET, value="current") public ResponseEntity getCurrent(Principal principal Long id