Skip to content
Advertisement

Tag: spring

Get size of json from MvcResult

I’m testing an API and get all data from the DB. I save the response as I get a json as response. I want to get the length of json array. So, if I have 2 rows in DB, I want to get 2 as a result. Or is there maybe another way to count number of rows which are

EnableConfigServer is not working for native location in spring boot

I am trying to configure a configuration server for all the properties in our application using @EnableConfigServer in spring boot. Please see the code below : pom.xml application.properties Copied all the property files to : /Users/Sankest/StarterProjects/MicroServices/AllConfigurations/ But when I try to access url at http://localhost:9090/config-server/default I am not seeing any property files and getting the following response: Answer Correct value

org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type ‘text/xml;charset=UTF-8’ not supported for bodyType

using Java 11, SpringBoot 2, WebFlux, WebClient and Jackson trying to use Spring WebClient to consume a Web service endpoint that returns XML, content type: ‘text/xml;charset=UTF-8’ Jackson XML dependency in the project’s pom.xml: WebClient code that triggers a request to external API and builds the response: ServiceResponse class (a simple POJO): resulting error: org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type ‘text/xml;charset=UTF-8’ not supported for

Spring Boot Error @Autowired RestTemplateBuilder with junit

Trying to @Autowired a RestTemplate in Spring Boot 2.1.4 using RestTemplateBuilder. When i run junit tests i get an error when trying to autowired RestTemplate. I saw here: How to autowire RestTemplate using annotations It seems that RestTemplateBuilder is better so i would like to use that. This is the configuration file : This is the test class: The error

Java interceptor not getting called

I have a Spring boot application and I am implementing and interceptor in order to log some data. The problem is that is not getting called, I have tried: And then I’ve applied to methods or classes and in both of them doesn’t work: Or Does someone knows what I am doing wrong? Thanks Answer If you are having a

java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl , when throwing BadRequestException

I have a handler class in my springbootapp that performs some validation on incoming REST requests and throws BadRequestException back to the controller class. But instead of controller catching the BadRequestException, it catches Exception and throws java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl I spend some time looking around for solution but dont seem to find any. Here is my validation code in handler Here

Set default Transaction Manager in @Transactional annotations?

I have a Spring Boot 2.x application with JPA/Hibernate and 2 separate Transaction Managers: 1 per-tenant and 1 application-wide. All entities, repositories and services are separated in different packages. Whenever I use @Transactional in my services, I need to explicitly qualify the txManager as either @Transactional(value = “tenantTransactionManager”) or @Transactional(value = “applicationTransactionManager”). This is very verbose and error prone since

Advertisement