spring-boot

mvn test fails but running the test from IntelliJ IDEA pass

随声附和 提交于 2021-02-11 18:10:47
问题 I have this a test that I run under @RunWith(SpringRunner.class) @SpringBootTest @Test public void testFind() throws IOException { Review<Hostel> hostelByComplaintId = hostelService.findByComplaintId(complaintId).orElse(null); assertThat(hostelByComplaintId).isNotNull(); } when I run the test from the command line mvn test I got this error Failed tests: Expecting actual not to be null but when I run it from IntelliJ IDEA, the test does not fail 回答1: You can just write complete command if

mvn test fails but running the test from IntelliJ IDEA pass

て烟熏妆下的殇ゞ 提交于 2021-02-11 18:10:39
问题 I have this a test that I run under @RunWith(SpringRunner.class) @SpringBootTest @Test public void testFind() throws IOException { Review<Hostel> hostelByComplaintId = hostelService.findByComplaintId(complaintId).orElse(null); assertThat(hostelByComplaintId).isNotNull(); } when I run the test from the command line mvn test I got this error Failed tests: Expecting actual not to be null but when I run it from IntelliJ IDEA, the test does not fail 回答1: You can just write complete command if

Current request is not a multipart request Spring Boot and Postman (Uploading json file plus extra field)

喜夏-厌秋 提交于 2021-02-11 17:58:39
问题 I'm getting this Current request is not a multipart request error when trying to upload a json file and an extra id or dto object for my request, since this is also required to populate my database. When I am sending only the json file, everything is being uploaded fine, but now I've added the id field to the related methods and Postman, I'm getting this message and struggling to debug and fix it, if I can get any help please. These are the pieces involved: @Controller @RequestMapping("/api

Can we have multiple readers(reading records through pagination) in a single batch job

巧了我就是萌 提交于 2021-02-11 17:52:25
问题 I have a spring batch job to be written . where : I need to read say 10k records through pagination(fetching 1000 rec at a time) (from azure SQL db) I need to use 1000 records at a time and then use one column of these records(say some id) to read corresponsing records from another cosmos db table. How do I implement 2 readers in this case as I need to read 1000 records at a time and again fetch records from cosmos db for those 1000 records first and process that. 回答1: There is a common

get application domain + port and path programmatically in spring?

百般思念 提交于 2021-02-11 17:51:32
问题 My website calls a rest service which is also on the same application. I don't want to change the domain of the rest address if it's hosted on a different domain name and/or port. I want to get the domain, port and application path programmatically. If we are accessing the website like http://example.com/article1 then I should get http://example.com or if our address is like below http://example.com:8080/ArticleSite/article1 then I want to get http://example.com:8080/ArticleSite How can this

Unable to synchronise Kafka and MQ transactions usingChainedKafkaTransaction

自作多情 提交于 2021-02-11 17:50:43
问题 We have a spring boot application which consumes messages from IBM MQ does some transformation and publishes the result to a Kafka topic. We use https://spring.io/projects/spring-kafka for this. I am aware that Kafka does not supports XA; however, in the documentation I found some inputs about using a ChainedKafkaTransactionManager to chain multiple transaction managers and synchronise the transactions. The same documentation also provides an example about how to synchronise Kafka and

How to merge client and server builds into one jar with gradle?

◇◆丶佛笑我妖孽 提交于 2021-02-11 17:35:43
问题 I have a project with the following structure: web-client/ # Angular Client build/ build.gradle server/ # Spring Boot Application build/ build.gradle build.gradle # The "parent" project. Works on web-client and server The parent is supposed to copy the compiled web-application into server/build/classes/static such that it will be copied to /BOOT-INF/classes/ of the final jar where it will be served by the Spring Boot server. Everything is working so far except the last part. Those files are

Java RestController REST parameter dependency injection or request

為{幸葍}努か 提交于 2021-02-11 17:19:25
问题 I am trying inject a dependency or at least filtrate the ID parameter that come into a RestControler in Spring. I am very new in Spring. How can i be sure that the parameter that comes passed in the API is valid and/or how can i inject its dependency related to Customer Entity? This is my rest controller CustomerController method @PatchMapping("/{id}") public Customer updateCustomer(@PathVariable Long id, @RequestBody Customer customer) { return customerService.updateCustomer(id, customer); }

Gradle fails to build at Test

浪子不回头ぞ 提交于 2021-02-11 17:18:20
问题 I have a spring boot project that has multiple modules each with its own gradle file. Spring boot version: 1.5.2.RELEASE gradle version:3.4 server (which includes main class) and other configurations shared (Utility classes used by other modules) service (module with various repository and services) transaction (module which handles transaction) I need to write test for the project but I cannot change the project structure. I created a test in my transaction module. The parent gradle file is

Gradle fails to build at Test

眉间皱痕 提交于 2021-02-11 17:14:32
问题 I have a spring boot project that has multiple modules each with its own gradle file. Spring boot version: 1.5.2.RELEASE gradle version:3.4 server (which includes main class) and other configurations shared (Utility classes used by other modules) service (module with various repository and services) transaction (module which handles transaction) I need to write test for the project but I cannot change the project structure. I created a test in my transaction module. The parent gradle file is